Commit fc675c76 by Chavee Issariyapat

rename topic for flowagent subscription

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