mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
make sure MQTT msg has a topic
This commit is contained in:
parent
5234fda266
commit
2a47951e46
@ -45,6 +45,7 @@ module.exports = function(RED) {
|
||||
this.status({fill:"red",shape:"ring",text:"disconnected"});
|
||||
this.client = connectionPool.get(this.brokerConfig.broker,this.brokerConfig.port,this.brokerConfig.clientid,this.brokerConfig.username,this.brokerConfig.password);
|
||||
var node = this;
|
||||
if (this.topic) {
|
||||
this.client.subscribe(this.topic,2,function(topic,payload,qos,retain) {
|
||||
if (isUtf8(payload)) { payload = payload.toString(); }
|
||||
var msg = {topic:topic,payload:payload,qos:qos,retain:retain};
|
||||
@ -60,6 +61,10 @@ module.exports = function(RED) {
|
||||
node.status({fill:"green",shape:"dot",text:"connected"});
|
||||
});
|
||||
this.client.connect();
|
||||
}
|
||||
else {
|
||||
this.error("topic not defined");
|
||||
}
|
||||
} else {
|
||||
this.error("missing broker configuration");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user