Commit fc675c76 by Chavee Issariyapat

rename topic for flowagent subscription

parent 6075f13f
...@@ -4,7 +4,7 @@ const events = require('events'); ...@@ -4,7 +4,7 @@ const events = require('events');
const Coordinator = function(param={}) { const Coordinator = function(param={}) {
let that = this; let that = this;
console.log(param) //console.log(param)
this.remoteclient = param.remoteclient; this.remoteclient = param.remoteclient;
this.localserver = param.localserver; this.localserver = param.localserver;
...@@ -15,9 +15,9 @@ const Coordinator = function(param={}) { ...@@ -15,9 +15,9 @@ const Coordinator = function(param={}) {
client.server.ascoltatore.subscribe(`${deviceid}/+`, function(topic, payload, options) { client.server.ascoltatore.subscribe(`${deviceid}/+`, function(topic, payload, options) {
client.forward(topic, payload, options, topic, 0); client.forward(topic, payload, options, topic, 0);
}); });
that.remoteclient.subscribe(`@shadow/data/updated/+/+/${deviceid}`); that.remoteclient.subscribe(`->tap/shadow/${deviceid}:${client.token}`);
that.remoteclient.subscribe(`@device/status/changed/+/+/${deviceid}`); that.remoteclient.subscribe(`->tap/device/${deviceid}:${client.token}`);
}); });
this.remoteclient.on('message', function(topic, payload){ this.remoteclient.on('message', function(topic, payload){
......
...@@ -17,6 +17,11 @@ MQTTServer.prototype.start = function() { ...@@ -17,6 +17,11 @@ MQTTServer.prototype.start = function() {
host : this.param.host host : this.param.host
}); });
this.mqttserver.authenticate = function(client, username, password, callback) {
client.token = username;
callback(null, true);
};
this.mqttserver.on('ready', function() { this.mqttserver.on('ready', function() {
console.log(`FlowAgent MQTT is up and running at ${that.param.port}`); console.log(`FlowAgent MQTT is up and running at ${that.param.port}`);
}); });
...@@ -38,8 +43,6 @@ MQTTServer.prototype.start = function() { ...@@ -38,8 +43,6 @@ MQTTServer.prototype.start = function() {
topic: topic topic: topic
}); });
}); });
} }
......
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