Commit 90979b08 by Chavee Issariyapat

handle shadow updated topic with additional part

parent 7a8fd03f
...@@ -99,13 +99,14 @@ const Coordinator = function(param={}) { ...@@ -99,13 +99,14 @@ const Coordinator = function(param={}) {
}); });
this.remoteclient.on('message', function(topic, payload){ this.remoteclient.on('message', function(topic, payload){
let jsonpayload = {}; let jsonpayload = {};
try { try {
jsonpayload = JSON.parse(payload.toString()); jsonpayload = JSON.parse(payload.toString());
} }
catch(e) {} catch(e) {}
if (topic == '@shadow/data/updated') { if (topic.startsWith('@shadow/data/updated')) {
let newpayload = cache.mergeShadow(jsonpayload.deviceid, jsonpayload); let newpayload = cache.mergeShadow(jsonpayload.deviceid, jsonpayload);
that.localserver.publish(`${jsonpayload.deviceid}/shadow/merged`, JSON.stringify(newpayload) ); that.localserver.publish(`${jsonpayload.deviceid}/shadow/merged`, JSON.stringify(newpayload) );
that.localserver.publish(`${jsonpayload.deviceid}/shadow/updated`, JSON.stringify(jsonpayload) ); that.localserver.publish(`${jsonpayload.deviceid}/shadow/updated`, JSON.stringify(jsonpayload) );
......
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