Commit 20e8460a by Chavee Issariyapat

add flowagent.js

parent 793014f7
module.exports.create = create
const MQTTClient = require('./mqttclient');
const MQTTServer = require('./mqttserver');
const Coordinatior = require('./coordinator');
const events = require('events');
let FlowAgent = function(options) {
let that = this;
this.remoteclient = MQTTClient.create({
host: options.remote_broker_uri,
options: {
clientId: options.flowagent_id,
username: options.flowagent_username,
password: options.flowagent_password,
keepalive: 30
}
});
this.localserver = MQTTServer.create({
host : options.localBrokerURI.hostname || '0.0.0.0',
port : parseInt(options.localBrokerURI.port) || 1883
});
this.coordinatior = Coordinatior.create({remoteclient: that.remoteclient, localserver: that.localserver});
}
FlowAgent.prototype = new events.EventEmitter;
FlowAgent.prototype.start = function() {
this.coordinatior.start();
}
function create(options) {
return FlowAgent(options);
}
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