js files
This commit is contained in:
34
dist/main.js
vendored
34
dist/main.js
vendored
@ -4,48 +4,26 @@ const log = require("./log");
|
||||
const mqtt = require("./mqttclient");
|
||||
class Dispatcher {
|
||||
constructor() {
|
||||
this._mqttClient = new mqtt.MqttClient();
|
||||
this._mqttClient.register('IoT/test', 'print1', (message) => {
|
||||
this._mqttDispatcher = new mqtt.MqttDispatcher();
|
||||
this._mqttDispatcher.register('IoT/test', 'print1', (message) => {
|
||||
log.info("Callback for IoT/test");
|
||||
log.info(`message is ${message}`);
|
||||
return `<<${message}>>`;
|
||||
});
|
||||
this._mqttClient.register('IoT/test', 'print2', (message) => {
|
||||
this._mqttDispatcher.register('IoT/test', 'print2', (message) => {
|
||||
log.info("Callback for IoT/test");
|
||||
log.info(`message is ${message}`);
|
||||
return `<<${message}>>`;
|
||||
});
|
||||
this._mqttClient.register('IoT/test', 'null1', mqtt.passThrough);
|
||||
this._mqttClient.register('IoT/test', 'null2', mqtt.passThrough);
|
||||
this._mqttDispatcher.register('IoT/test', 'null1', mqtt.passThrough);
|
||||
this._mqttDispatcher.register('IoT/test', 'null2', mqtt.passThrough);
|
||||
}
|
||||
exec() {
|
||||
log.info("Dispatcher starting");
|
||||
this._mqttClient.exec();
|
||||
this._mqttDispatcher.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
|
7
dist/mqttclient.js
vendored
7
dist/mqttclient.js
vendored
@ -8,7 +8,7 @@ function passThrough(message) {
|
||||
return message;
|
||||
}
|
||||
exports.passThrough = passThrough;
|
||||
class MqttClient {
|
||||
class MqttDispatcher {
|
||||
constructor(mqttBrokerUrl) {
|
||||
this._mqttBrokerUrl = (mqttBrokerUrl) ? mqttBrokerUrl : MQTT_BROKER_DEFAULT_URL;
|
||||
this._topicHandlers = [];
|
||||
@ -37,9 +37,6 @@ class MqttClient {
|
||||
log.info(`first callback ${newChainItem.toString()} added for topic ${topic}`);
|
||||
}
|
||||
}
|
||||
test() {
|
||||
this._mqttClient.emit("message", 'IoT/test', 'payload');
|
||||
}
|
||||
exec() {
|
||||
for (let topicHandler of this._topicHandlers) {
|
||||
topicHandler.root.begin();
|
||||
@ -88,5 +85,5 @@ class MqttClient {
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.MqttClient = MqttClient;
|
||||
exports.MqttDispatcher = MqttDispatcher;
|
||||
//# sourceMappingURL=mqttclient.js.map
|
Reference in New Issue
Block a user