Allow msg.reset to reset connection when tcp request in stay connected mode

This commit is contained in:
Dave Conway-Jones 2023-11-01 12:07:50 +00:00
parent eb940d6d57
commit f2cb5ea44e
No known key found for this signature in database
GPG Key ID: 1DDB0E91A28C2643

View File

@ -547,10 +547,16 @@ module.exports = function(RED) {
this.on("input", function(msg, nodeSend, nodeDone) {
var i = 0;
if ((!Buffer.isBuffer(msg.payload)) && (typeof msg.payload !== "string")) {
if (msg.payload !== undefined && (!Buffer.isBuffer(msg.payload)) && (typeof msg.payload !== "string")) {
msg.payload = msg.payload.toString();
}
if (node.out === "sit" && msg?.reset === true && node?.last_id && clients[node.last_id]) {
node.status({});
clients[node.last_id].client.destroy();
delete clients[node.last_id];
}
var host = node.server || msg.host;
var port = node.port || msg.port;
@ -627,7 +633,9 @@ module.exports = function(RED) {
clients[connection_id].connecting = false;
let event;
while (event = dequeue(clients[connection_id].msgQueue)) {
clients[connection_id].client.write(event.msg.payload);
if (event.msg.payload !== undefined) {
clients[connection_id].client.write(event.msg.payload);
}
event.nodeDone();
}
if (node.out === "time" && node.splitc < 0) {