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