From e270da87108c532afcbd80501c2c52cb8533de38 Mon Sep 17 00:00:00 2001 From: Jens Reimann Date: Mon, 21 Nov 2022 13:02:34 +0100 Subject: [PATCH] fix(binding-mqtt): receiving of MQTT commands Receiving of MQTT commands is currently broken. The reason for this is, that the callback is registered in a way that the "this" context is dropped. Also see: https://stackoverflow.com/questions/20279484/how-to-access-the-correct-this-inside-a-callback --- packages/binding-mqtt/src/mqtt-broker-server.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/binding-mqtt/src/mqtt-broker-server.ts b/packages/binding-mqtt/src/mqtt-broker-server.ts index fca4ce548..1bff40b62 100644 --- a/packages/binding-mqtt/src/mqtt-broker-server.ts +++ b/packages/binding-mqtt/src/mqtt-broker-server.ts @@ -115,7 +115,7 @@ export default class MqttBrokerServer implements ProtocolServer { } // connect incoming messages to Thing - this.broker.on("message", this.handleMessage); + this.broker.on("message", this.handleMessage.bind(this)); this.broker.publish(name, JSON.stringify(thing.getThingDescription()), { retain: true }); }