Commit a4eb9e32 by Chavee Issariyapat

rename tap topic

parent 73d12a3b
......@@ -17,8 +17,8 @@ const Coordinator = function(param={}) {
});
if (that.localserver.sublist[deviceid] == undefined) {
that.remoteclient.subscribe(`->tap/shadow/${deviceid}:${client.token}`);
that.remoteclient.subscribe(`->tap/device/${deviceid}:${client.token}`);
that.remoteclient.subscribe(`@tap/shadow/${deviceid}:${client.token}`);
that.remoteclient.subscribe(`@tap/device/${deviceid}:${client.token}`);
that.localserver.sublist[deviceid] = {
count : 1,
token : client.token
......@@ -34,8 +34,8 @@ const Coordinator = function(param={}) {
let deviceid = client.id.split(':')[0];
if (that.localserver.sublist[deviceid].count <= 1) {
that.remoteclient.unsubscribe(`@tap/shadow/${deviceid}:${client.token}`);
that.remoteclient.unsubscribe(`@tap/device/${deviceid}:${client.token}`);
that.remoteclient.unsubscribe(`@tap/shadow/updated/${deviceid}:${client.token}`);
that.remoteclient.unsubscribe(`@tap/device/changed/${deviceid}:${client.token}`);
delete that.localserver.sublist[deviceid];
}
else {
......@@ -45,7 +45,7 @@ const Coordinator = function(param={}) {
this.localserver.on('clientPublished', function(packet, client){
console.log('client published', client.id);
let tap_topic = `@tap/shadow/${client.id}:${client.token}`;
let tap_topic = `@tap/shadow/update/${client.id}:${client.token}`;
let msg = packet.payload.toString();
......@@ -57,8 +57,8 @@ const Coordinator = function(param={}) {
setTimeout(function() {
for (let deviceid in that.localserver.sublist) {
//console.log(deviceid, that.localserver.sublist[deviceid])
that.remoteclient.subscribe(`@tap/shadow/${deviceid}:${that.localserver.sublist[deviceid].token}`);
that.remoteclient.subscribe(`@tap/device/${deviceid}:${that.localserver.sublist[deviceid].token}`);
that.remoteclient.subscribe(`@tap/shadow/updated/${deviceid}:${that.localserver.sublist[deviceid].token}`);
that.remoteclient.subscribe(`@tap/device/changed/${deviceid}:${that.localserver.sublist[deviceid].token}`);
}
}, 2000);
});
......
......@@ -6,7 +6,7 @@
"scripts": {
"start": "node index.js"
},
"author": "NEXPIE Company Limited (https://nexpie.com)"
"author": "NEXPIE Company Limited (https://nexpie.com)",
"license": "ISC",
"dependencies": {
"config": "^3.2.4",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment