preset fix
This commit is contained in:
8
dist/MqttDispatcher.js
vendored
8
dist/MqttDispatcher.js
vendored
@ -17,13 +17,15 @@ class MqttHandler {
|
||||
this.mqttOptions.rejectUnauthorized = true;
|
||||
}
|
||||
this.topicHandlers = [];
|
||||
this.startCallbacks = [];
|
||||
logger.info("MqttHandler constructed");
|
||||
}
|
||||
register(topics, cb) {
|
||||
register(topics, cb, startCb) {
|
||||
topics.forEach((topic) => {
|
||||
this.topicHandlers.push({ topic: topic, callback: cb });
|
||||
logger.info(`Callback registered for ${topic}`);
|
||||
});
|
||||
this.startCallbacks.push(startCb);
|
||||
}
|
||||
exec() {
|
||||
logger.info(`Connecting to ${this.mqttBrokerUrl}`);
|
||||
@ -39,6 +41,10 @@ class MqttHandler {
|
||||
logger.info(`${topicHandler.topic} subscribed`);
|
||||
});
|
||||
logger.info('MQTT connection established');
|
||||
this.startCallbacks.forEach((cb) => {
|
||||
cb();
|
||||
logger.info("started");
|
||||
});
|
||||
});
|
||||
this.mqttClient.on('message', (topic, payload, packet) => {
|
||||
if (!packet.retain) {
|
||||
|
Reference in New Issue
Block a user