2017-08-09 00:03:57 +02:00

51 lines
1.7 KiB
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const log = require("./log");
const mqtt = require("./mqttclient");
class Dispatcher {
constructor() {
this._mqttClient = new mqtt.MqttClient();
this._mqttClient.registerCallbackFunc('IoT/test', 'print1', (message) => {
log.info("Callback for IoT/test");
log.info(`message is ${message}`);
return `<<${message}>>`;
});
this._mqttClient.registerCallbackFunc('IoT/test', 'print2', (message) => {
log.info("Callback for IoT/test");
log.info(`message is ${message}`);
return `<<${message}>>`;
});
this._mqttClient.registerCallbackFunc('IoT/test', 'null1', mqtt.passThrough);
this._mqttClient.registerCallbackFunc('IoT/test', 'null2', mqtt.passThrough);
}
exec() {
log.info("Dispatcher starting");
this._mqttClient.exec();
log.info("Dispatcher running");
}
test() {
log.info("Sending test data");
this._mqttClient.test();
}
}
// callchain.registerChainItemFunc('first', (message : any) : any => {
// log.info(`first callback ${message}`)
// return `<${message}>`
// })
// callchain.registerChainItemFunc('second', (message : any) : any => {
// log.info(`second callback ${message}`)
// return `<${message}>`
// })
// callchain.registerChainItemFunc('third', (message : any) : any => {
// log.info(`third callback ${message}`)
// return `<${message}>`
// })
// callchain.begin()
// callchain.send('test1')
// callchain.send('test2')
// callchain.send('test3')
// callchain.send('test4')
const dispatcher = new Dispatcher();
dispatcher.exec();
dispatcher.test();
//# sourceMappingURL=main.js.map