From dd7f313d0c6db72fb076b79e2c420f4dec4cbc8d Mon Sep 17 00:00:00 2001 From: Wolfgang Hottgenroth Date: Wed, 9 Aug 2017 00:21:14 +0200 Subject: [PATCH] js files --- dist/main.js | 34 ++++++---------------------------- dist/mqttclient.js | 7 ++----- 2 files changed, 8 insertions(+), 33 deletions(-) diff --git a/dist/main.js b/dist/main.js index ee7a793..28268bb 100644 --- a/dist/main.js +++ b/dist/main.js @@ -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 \ No newline at end of file diff --git a/dist/mqttclient.js b/dist/mqttclient.js index 45a965f..ba5cdd1 100644 --- a/dist/mqttclient.js +++ b/dist/mqttclient.js @@ -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 \ No newline at end of file