Commit 90979b08 by Chavee Issariyapat

handle shadow updated topic with additional part

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