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

TCP node: pass on latest input msg properties

to close #944
This commit is contained in:
Dave Conway-Jones 2016-08-04 15:49:38 +01:00
parent 022d066fe0
commit 42f4e0fa86

View File

@ -396,8 +396,7 @@ module.exports = function(RED) {
else { else {
if (this.splitc[0] == '\\') { if (this.splitc[0] == '\\') {
this.splitc = parseInt(this.splitc.replace("\\n",0x0A).replace("\\r",0x0D).replace("\\t",0x09).replace("\\e",0x1B).replace("\\f",0x0C).replace("\\0",0x00)); this.splitc = parseInt(this.splitc.replace("\\n",0x0A).replace("\\r",0x0D).replace("\\t",0x09).replace("\\e",0x1B).replace("\\f",0x0C).replace("\\0",0x00));
} } // jshint ignore:line
if (typeof this.splitc == "string") { if (typeof this.splitc == "string") {
if (this.splitc.substr(0,2) == "0x") { if (this.splitc.substr(0,2) == "0x") {
this.splitc = parseInt(this.splitc); this.splitc = parseInt(this.splitc);
@ -405,8 +404,8 @@ module.exports = function(RED) {
else { else {
this.splitc = this.splitc.charCodeAt(0); this.splitc = this.splitc.charCodeAt(0);
} }
} } // jshint ignore:line
} // jshint ignore:line }
var buf; var buf;
if (this.out == "count") { if (this.out == "count") {
@ -418,8 +417,10 @@ module.exports = function(RED) {
this.connected = false; this.connected = false;
var node = this; var node = this;
var client; var client;
var m;
this.on("input", function(msg) { this.on("input", function(msg) {
m = msg;
var i = 0; var i = 0;
if ((!Buffer.isBuffer(msg.payload)) && (typeof msg.payload !== "string")) { if ((!Buffer.isBuffer(msg.payload)) && (typeof msg.payload !== "string")) {
msg.payload = msg.payload.toString(); msg.payload = msg.payload.toString();
@ -444,8 +445,8 @@ 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
msg.payload = data; m.payload = data;
node.send(msg); node.send(m);
} }
else if (node.splitc === 0) { else if (node.splitc === 0) {
msg.payload = data; msg.payload = data;