From cfb8ab7e922836bf3bf60baba4ae9c079e682813 Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Tue, 9 Jun 2015 10:07:11 +0100 Subject: [PATCH] Fix multiple mqlight node subscriber issue --- io/mqlight/mqlight.js | 22 ++++++++++++---------- io/mqlight/package.json | 2 +- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/io/mqlight/mqlight.js b/io/mqlight/mqlight.js index 1a2a73f7..1a95f4a1 100644 --- a/io/mqlight/mqlight.js +++ b/io/mqlight/mqlight.js @@ -62,18 +62,20 @@ module.exports = function(RED) { var recvClient = node.serviceConfig.client; recvClient.on("started", function() { recvClient.on("message", function(data, delivery) { - var msg = { - topic: delivery.message.topic, - payload: data, - _session: { - type: "mqlight", - id: recvClient.id + if (node.topic === delivery.destination.topicPattern) { + var msg = { + topic: delivery.message.topic, + payload: data, + _session: { + type: "mqlight", + id: recvClient.id + } + }; + if (delivery.destination.share) { + msg.share = delivery.destination.share; } - }; - if (delivery.destination.share) { - msg.share = delivery.destination.share; + node.send(msg); } - node.send(msg); }); recvClient.on("error", function(err) { if (err) { diff --git a/io/mqlight/package.json b/io/mqlight/package.json index 67004b6c..c36be234 100644 --- a/io/mqlight/package.json +++ b/io/mqlight/package.json @@ -1,6 +1,6 @@ { "name" : "node-red-node-mqlight", - "version" : "0.0.6", + "version" : "0.0.7", "description" : "A Node-RED node to send and receive message from IBM MQ Light", "dependencies" : { "mqlight" : "1.0.x"