overloaded register func in mqttclilent
This commit is contained in:
16
dist/mqttclient.js
vendored
16
dist/mqttclient.js
vendored
@ -13,12 +13,16 @@ class MqttClient {
|
||||
this._mqttBrokerUrl = (mqttBrokerUrl) ? mqttBrokerUrl : MQTT_BROKER_DEFAULT_URL;
|
||||
this._topicHandlers = [];
|
||||
}
|
||||
registerCallbackFunc(topic, label, callbackFunc) {
|
||||
let newChainItem = new callchain.ChainItem(label);
|
||||
newChainItem.registerFunc(callbackFunc);
|
||||
this.registerCallbackClass(topic, label, newChainItem);
|
||||
}
|
||||
registerCallbackClass(topic, label, newChainItem) {
|
||||
register(topic, label, newChainItemOrCallbackFunc) {
|
||||
let newChainItem;
|
||||
if (newChainItemOrCallbackFunc instanceof callchain.AChainItem) {
|
||||
newChainItem = newChainItemOrCallbackFunc;
|
||||
}
|
||||
else {
|
||||
let myNewChainItem = new callchain.ChainItem(label);
|
||||
myNewChainItem.registerFunc(newChainItemOrCallbackFunc);
|
||||
newChainItem = myNewChainItem;
|
||||
}
|
||||
let done = false;
|
||||
for (let topicHandler of this._topicHandlers) {
|
||||
if (topicHandler.topic === topic) {
|
||||
|
Reference in New Issue
Block a user