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

Don't send message if it doesn't exist. and give it time not to exist.

to close #1527
This commit is contained in:
Dave Conway-Jones 2017-12-19 17:52:35 +00:00
parent fc6748a46b
commit f737ea96f3
No known key found for this signature in database
GPG Key ID: 9E7F9C73F5168CD4
2 changed files with 6 additions and 4 deletions

View File

@ -127,17 +127,19 @@ module.exports = function(RED) {
node.status({fill:"blue",shape:"dot",text:" "});
}
else if ((node.extend === "true" || node.extend === true) && (node.duration > 0)) {
if (node.topics[topic].tout) { clearTimeout(node.topics[topic].tout); }
if (node.op2type === "payl") { node.topics[topic].m2 = RED.util.cloneMessage(msg.payload); }
if (node.topics[topic].tout) { clearTimeout(node.topics[topic].tout); }
node.topics[topic].tout = setTimeout(function() {
if (node.op2type !== "nul") {
var msg2 = RED.util.cloneMessage(msg);
if (node.op2type === "flow" || node.op2type === "global") {
node.topics[topic].m2 = RED.util.evaluateNodeProperty(node.op2,node.op2type,node,msg);
}
if (node.topics[topic] !== undefined) {
msg2.payload = node.topics[topic].m2;
node.send(msg2);
}
}
delete node.topics[topic];
node.status({});
}, node.duration);

View File

@ -282,7 +282,7 @@ describe('trigger node', function() {
n1.emit("input", {payload:1,topic:"A"});
n1.emit("input", {payload:2,topic:"B"});
n1.emit("input", {payload:3,topic:"C"});
setTimeout( function() { n1.emit("input", {payload:2,topic:"B"})}, 25 );
setTimeout( function() { n1.emit("input", {payload:2,topic:"B"})}, 20 );
});
});