2017-07-22 23:39:14 +02:00
|
|
|
"use strict";
|
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
|
const log = require("./log");
|
2017-07-27 23:38:17 +02:00
|
|
|
const mqtt = require("./mqttclient");
|
2017-07-22 23:39:14 +02:00
|
|
|
class Dispatcher {
|
|
|
|
constructor() {
|
2017-07-27 23:38:17 +02:00
|
|
|
this._mqttClient = new mqtt.MqttClient();
|
2017-08-09 00:03:57 +02:00
|
|
|
this._mqttClient.registerCallbackFunc('IoT/test', 'print1', (message) => {
|
2017-07-27 23:38:17 +02:00
|
|
|
log.info("Callback for IoT/test");
|
|
|
|
log.info(`message is ${message}`);
|
|
|
|
return `<<${message}>>`;
|
|
|
|
});
|
2017-08-09 00:03:57 +02:00
|
|
|
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);
|
2017-07-22 23:39:14 +02:00
|
|
|
}
|
|
|
|
exec() {
|
|
|
|
log.info("Dispatcher starting");
|
|
|
|
this._mqttClient.exec();
|
2017-07-23 22:55:05 +02:00
|
|
|
log.info("Dispatcher running");
|
2017-07-22 23:39:14 +02:00
|
|
|
}
|
2017-08-09 00:03:57 +02:00
|
|
|
test() {
|
|
|
|
log.info("Sending test data");
|
|
|
|
this._mqttClient.test();
|
|
|
|
}
|
2017-07-22 23:39:14 +02:00
|
|
|
}
|
2017-08-09 00:03:57 +02:00
|
|
|
// 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')
|
2017-07-22 23:39:14 +02:00
|
|
|
const dispatcher = new Dispatcher();
|
|
|
|
dispatcher.exec();
|
2017-08-09 00:03:57 +02:00
|
|
|
dispatcher.test();
|
2017-07-22 23:39:14 +02:00
|
|
|
//# sourceMappingURL=main.js.map
|