some changes

This commit is contained in:
Wolfgang Hottgenroth
2017-07-27 23:38:17 +02:00
parent 8685bdde87
commit 7e236974c2
4 changed files with 29 additions and 17 deletions

8
dist/mqttclient.js vendored
View File

@ -3,6 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
const Mqtt = require("mqtt");
const log = require("./log");
const MQTT_BROKER_DEFAULT_URL = "mqtt://localhost";
function passThrough(message) {
return message;
}
exports.passThrough = passThrough;
class MqttClient {
constructor(mqttBrokerUrl) {
this._mqttBrokerUrl = (mqttBrokerUrl) ? mqttBrokerUrl : MQTT_BROKER_DEFAULT_URL;
@ -26,9 +30,7 @@ class MqttClient {
for (let topicHandler of this._topicHandlers) {
if (this.topicMatch(topicHandler.topic, topic)) {
log.info(`received topic ${topic} matches registered topic ${topicHandler.topic}`);
if (topicHandler.callback != null) {
topicHandler.callback(payload);
}
topicHandler.callback(payload);
}
}
});