Merge branch 'dev-V0.4.5' into dev-V0.4.5-postgre
commit
c9d4bc346a
|
@ -177,6 +177,20 @@ function subRegister(topic, parent, payload) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function deviceStateChangeByClientId(head, clientId, state) {
|
||||||
|
|
||||||
|
var device = getPkDn(clientId);
|
||||||
|
|
||||||
|
return {
|
||||||
|
type: "state",
|
||||||
|
data: {
|
||||||
|
productKey: device.pk,
|
||||||
|
deviceName: device.dn,
|
||||||
|
state: state
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function deviceStateChange(head, clientId, state) {
|
function deviceStateChange(head, clientId, state) {
|
||||||
var topic = head.topic;
|
var topic = head.topic;
|
||||||
var device = getPkDn(clientId);
|
var device = getPkDn(clientId);
|
||||||
|
@ -243,20 +257,24 @@ this.onReceive = function (head, type, payload) {
|
||||||
if (type == 'auth') {
|
if (type == 'auth') {
|
||||||
return register(payload);
|
return register(payload);
|
||||||
}
|
}
|
||||||
|
else if (type == 'online') {
|
||||||
if (type == 'subscribe') {
|
return deviceStateChangeByClientId(head, payload, 'online');
|
||||||
return deviceStateChange(head, payload, 'online');
|
}
|
||||||
|
else if (type == 'subscribe') {
|
||||||
|
// 此产品无需通过订阅来确认是否上线
|
||||||
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == 'unsubscribe') {
|
else if (type == 'unsubscribe') {
|
||||||
return deviceStateChange(head, payload, 'offline');
|
// 此产品无需通过订阅来确认是否下线
|
||||||
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == 'disconnect') {
|
else if (type == 'disconnect') {
|
||||||
return disconnect(payload);
|
return disconnect(payload);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == 'ota') {
|
else if (type == 'ota') {
|
||||||
return ota(head, payload);
|
return ota(head, payload);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -90,6 +90,8 @@ public class NBVerticle extends AbstractVerticle {
|
||||||
endpoint.reject(MqttConnectReturnCode.CONNECTION_REFUSED_NOT_AUTHORIZED);
|
endpoint.reject(MqttConnectReturnCode.CONNECTION_REFUSED_NOT_AUTHORIZED);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// 固定协议,不需要订阅,直接认为上线
|
||||||
|
executor.onReceive(null, "online", clientId);
|
||||||
//保存设备与连接关系
|
//保存设备与连接关系
|
||||||
endpointMap.put(getEndpointKey(r), endpoint);
|
endpointMap.put(getEndpointKey(r), endpoint);
|
||||||
mqttConnectPool.put(clientId, true);
|
mqttConnectPool.put(clientId, true);
|
||||||
|
|
|
@ -177,6 +177,20 @@ function subRegister(topic, parent, payload) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function deviceStateChangeByClientId(head, clientId, state) {
|
||||||
|
|
||||||
|
var device = getPkDn(clientId);
|
||||||
|
|
||||||
|
return {
|
||||||
|
type: "state",
|
||||||
|
data: {
|
||||||
|
productKey: device.pk,
|
||||||
|
deviceName: device.dn,
|
||||||
|
state: state
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function deviceStateChange(head, clientId, state) {
|
function deviceStateChange(head, clientId, state) {
|
||||||
var topic = head.topic;
|
var topic = head.topic;
|
||||||
var device = getPkDn(clientId);
|
var device = getPkDn(clientId);
|
||||||
|
@ -243,20 +257,24 @@ this.onReceive = function (head, type, payload) {
|
||||||
if (type == 'auth') {
|
if (type == 'auth') {
|
||||||
return register(payload);
|
return register(payload);
|
||||||
}
|
}
|
||||||
|
else if (type == 'online') {
|
||||||
if (type == 'subscribe') {
|
return deviceStateChangeByClientId(head, payload, 'online');
|
||||||
return deviceStateChange(head, payload, 'online');
|
}
|
||||||
|
else if (type == 'subscribe') {
|
||||||
|
// 此产品无需通过订阅来确认是否上线
|
||||||
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == 'unsubscribe') {
|
else if (type == 'unsubscribe') {
|
||||||
return deviceStateChange(head, payload, 'offline');
|
// 此产品无需通过订阅来确认是否下线
|
||||||
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == 'disconnect') {
|
else if (type == 'disconnect') {
|
||||||
return disconnect(payload);
|
return disconnect(payload);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == 'ota') {
|
else if (type == 'ota') {
|
||||||
return ota(head, payload);
|
return ota(head, payload);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue