Fix TCP node sending data

(it’s for the children)
This commit is contained in:
Dave Conway-Jones 2015-08-17 17:15:44 +01:00
parent 2d4979df4d
commit 2fe568d9ba
1 changed files with 7 additions and 4 deletions

View File

@ -432,7 +432,7 @@ module.exports = function(RED) {
m = new Buffer(i+1); m = new Buffer(i+1);
buf.copy(m,0,0,i+1); buf.copy(m,0,0,i+1);
node.send({"payload":m}); node.send({"payload":m});
if (client) { client.end(); } //if (client) { client.end(); }
}, node.splitc); }, node.splitc);
i = 0; i = 0;
buf[0] = data[j]; buf[0] = data[j];
@ -445,7 +445,8 @@ module.exports = function(RED) {
if ( i >= node.splitc) { if ( i >= node.splitc) {
m = new Buffer(i); m = new Buffer(i);
buf.copy(m,0,0,i); buf.copy(m,0,0,i);
if (client) { client.end(); } node.send({"payload":m});
//if (client) { client.end(); }
i = 0; i = 0;
} }
} }
@ -456,7 +457,8 @@ module.exports = function(RED) {
if (data[j] == node.splitc) { if (data[j] == node.splitc) {
m = new Buffer(i); m = new Buffer(i);
buf.copy(m,0,0,i); buf.copy(m,0,0,i);
if (client) { client.end(); } node.send({"payload":m});
//if (client) { client.end(); }
i = 0; i = 0;
} }
} }
@ -472,6 +474,7 @@ module.exports = function(RED) {
}); });
client.on('close', function() { client.on('close', function() {
node.status({});
if (node.done) { node.done(); } if (node.done) { node.done(); }
}); });
@ -501,7 +504,7 @@ module.exports = function(RED) {
node.done = done; node.done = done;
if (client) { if (client) {
buf = null; buf = null;
client.end(); client.destroy();
} }
if (!node.connected) { done(); } if (!node.connected) { done(); }
}); });