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

websocket - preserve _session on msg but don't send as part of wholemsg

This commit is contained in:
Dave Conway-Jones 2018-09-23 10:34:22 +01:00
parent 80a15089b4
commit f5bebef37f
No known key found for this signature in database
GPG Key ID: 9E7F9C73F5168CD4

View File

@ -250,9 +250,12 @@ module.exports = function(RED) {
this.on("input", function(msg) { this.on("input", function(msg) {
var payload; var payload;
if (this.serverConfig.wholemsg) { if (this.serverConfig.wholemsg) {
var sess = ""+msg._session;
delete msg._session; delete msg._session;
payload = JSON.stringify(msg); payload = JSON.stringify(msg);
} else if (msg.hasOwnProperty("payload")) { msg._session = sess;
}
else if (msg.hasOwnProperty("payload")) {
if (!Buffer.isBuffer(msg.payload)) { // if it's not a buffer make sure it's a string. if (!Buffer.isBuffer(msg.payload)) { // if it's not a buffer make sure it's a string.
payload = RED.util.ensureString(msg.payload); payload = RED.util.ensureString(msg.payload);
} }