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

Let TCPget node pass through other msg properties

This commit is contained in:
Dave Conway-Jones 2015-12-11 14:07:17 +00:00
parent 371f72f4f1
commit 2685a24705

View File

@ -418,10 +418,12 @@ module.exports = function(RED) {
client.on('data', function(data) { client.on('data', function(data) {
if (node.out == "sit") { // if we are staying connected just send the buffer if (node.out == "sit") { // if we are staying connected just send the buffer
node.send({"payload": data}); msg.payload = data;
node.send(msg);
} }
else if (node.splitc === 0) { else if (node.splitc === 0) {
node.send({"payload": data}); msg.payload = data;
node.send(msg);
} }
else { else {
for (var j = 0; j < data.length; j++ ) { for (var j = 0; j < data.length; j++ ) {
@ -434,9 +436,9 @@ module.exports = function(RED) {
else { else {
node.tout = setTimeout(function () { node.tout = setTimeout(function () {
node.tout = null; node.tout = null;
m = new Buffer(i+1); msg.payload = new Buffer(i+1);
buf.copy(m,0,0,i+1); buf.copy(msg.payload,0,0,i+1);
node.send({"payload":m}); node.send(msg);
//if (client) { client.end(); } //if (client) { client.end(); }
}, node.splitc); }, node.splitc);
i = 0; i = 0;
@ -448,9 +450,9 @@ module.exports = function(RED) {
buf[i] = data[j]; buf[i] = data[j];
i += 1; i += 1;
if ( i >= node.splitc) { if ( i >= node.splitc) {
m = new Buffer(i); msg.payload = new Buffer(i);
buf.copy(m,0,0,i); buf.copy(msg.payload,0,0,i);
node.send({"payload":m}); node.send(msg);
//if (client) { client.end(); } //if (client) { client.end(); }
i = 0; i = 0;
} }
@ -460,9 +462,9 @@ module.exports = function(RED) {
buf[i] = data[j]; buf[i] = data[j];
i += 1; i += 1;
if (data[j] == node.splitc) { if (data[j] == node.splitc) {
m = new Buffer(i); msg.payload = new Buffer(i);
buf.copy(m,0,0,i); buf.copy(msg.payload,0,0,i);
node.send({"payload":m}); node.send(msg);
//if (client) { client.end(); } //if (client) { client.end(); }
i = 0; i = 0;
} }
@ -475,7 +477,8 @@ module.exports = function(RED) {
//console.log("END"); //console.log("END");
node.connected = false; node.connected = false;
node.status({fill:"grey",shape:"ring",text:"common.status.disconnected"}); node.status({fill:"grey",shape:"ring",text:"common.status.disconnected"});
node.send({"payload":m}); msg.payload = null;
node.send(msg);
client = null; client = null;
}); });