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
1 changed files with 15 additions and 12 deletions

View File

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