1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

MQTT Node: allow publishing of Buffer payloads

Closes #341
This commit is contained in:
Nick O'Leary 2014-08-18 11:27:52 +01:00
parent 3c31ef4643
commit 907ce5c079

View File

@ -213,12 +213,12 @@ MQTTClient.prototype.publish = function(topic,payload,qos,retain) {
var self = this; var self = this;
if (self.connected) { if (self.connected) {
if (Buffer.isBuffer(payload)) { if (!Buffer.isBuffer(payload)) {
payload = payload.toString(); if (typeof payload === "object") {
} else if (typeof payload === "object") { payload = JSON.stringify(payload);
payload = JSON.stringify(payload); } else if (typeof payload !== "string") {
} else if (typeof payload !== "string") { payload = ""+payload;
payload = ""+payload; }
} }
var options = { var options = {
topic: topic, topic: topic,