callback name
This commit is contained in:
1
dist/main.js
vendored
1
dist/main.js
vendored
@ -11,6 +11,7 @@ class Dispatcher {
|
|||||||
return `<<${message}>>`;
|
return `<<${message}>>`;
|
||||||
});
|
});
|
||||||
this._mqttClient.register('IoT/Device/#', mqtt.passThrough);
|
this._mqttClient.register('IoT/Device/#', mqtt.passThrough);
|
||||||
|
this._mqttClient.register('IoT/Device/#', mqtt.passThrough);
|
||||||
}
|
}
|
||||||
exec() {
|
exec() {
|
||||||
log.info("Dispatcher starting");
|
log.info("Dispatcher starting");
|
||||||
|
5
dist/mqttclient.js
vendored
5
dist/mqttclient.js
vendored
@ -14,17 +14,18 @@ class MqttClient {
|
|||||||
}
|
}
|
||||||
register(topic, callback) {
|
register(topic, callback) {
|
||||||
let done = false;
|
let done = false;
|
||||||
|
let callbackName = (callback.name === "") ? "lambda" : callback.name;
|
||||||
for (let topicHandler of this._topicHandlers) {
|
for (let topicHandler of this._topicHandlers) {
|
||||||
if (topicHandler.topic === topic) {
|
if (topicHandler.topic === topic) {
|
||||||
topicHandler.callbacks.push(callback);
|
topicHandler.callbacks.push(callback);
|
||||||
done = true;
|
done = true;
|
||||||
log.info(`additional callback added for topic ${topic}`);
|
log.info(`additional callback <${callbackName}> added for topic ${topic}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!done) {
|
if (!done) {
|
||||||
let cbs = [callback];
|
let cbs = [callback];
|
||||||
this._topicHandlers.push({ topic: topic, callbacks: cbs });
|
this._topicHandlers.push({ topic: topic, callbacks: cbs });
|
||||||
log.info(`first callback added for topic ${topic}`);
|
log.info(`first callback <${callbackName}> added for topic ${topic}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exec() {
|
exec() {
|
||||||
|
@ -13,6 +13,7 @@ class Dispatcher {
|
|||||||
return `<<${message}>>`
|
return `<<${message}>>`
|
||||||
})
|
})
|
||||||
this._mqttClient.register('IoT/Device/#', mqtt.passThrough)
|
this._mqttClient.register('IoT/Device/#', mqtt.passThrough)
|
||||||
|
this._mqttClient.register('IoT/Device/#', mqtt.passThrough)
|
||||||
}
|
}
|
||||||
|
|
||||||
exec() : void {
|
exec() : void {
|
||||||
|
@ -26,17 +26,18 @@ export class MqttClient {
|
|||||||
|
|
||||||
register(topic: string, callback: TopicHandlerCallback) : void {
|
register(topic: string, callback: TopicHandlerCallback) : void {
|
||||||
let done: boolean = false
|
let done: boolean = false
|
||||||
|
let callbackName : string = (callback.name === "") ? "lambda" : callback.name
|
||||||
for (let topicHandler of this._topicHandlers) {
|
for (let topicHandler of this._topicHandlers) {
|
||||||
if (topicHandler.topic === topic) {
|
if (topicHandler.topic === topic) {
|
||||||
topicHandler.callbacks.push(callback)
|
topicHandler.callbacks.push(callback)
|
||||||
done = true
|
done = true
|
||||||
log.info(`additional callback added for topic ${topic}`)
|
log.info(`additional callback <${callbackName}> added for topic ${topic}`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (! done) {
|
if (! done) {
|
||||||
let cbs : TopicHandlerCallback[] = [ callback ]
|
let cbs : TopicHandlerCallback[] = [ callback ]
|
||||||
this._topicHandlers.push({topic:topic, callbacks:cbs})
|
this._topicHandlers.push({topic:topic, callbacks:cbs})
|
||||||
log.info(`first callback added for topic ${topic}`)
|
log.info(`first callback <${callbackName}> added for topic ${topic}`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user