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:
parent
fc6748a46b
commit
f737ea96f3
@ -127,17 +127,19 @@ module.exports = function(RED) {
|
|||||||
node.status({fill:"blue",shape:"dot",text:" "});
|
node.status({fill:"blue",shape:"dot",text:" "});
|
||||||
}
|
}
|
||||||
else if ((node.extend === "true" || node.extend === true) && (node.duration > 0)) {
|
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.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() {
|
node.topics[topic].tout = setTimeout(function() {
|
||||||
if (node.op2type !== "nul") {
|
if (node.op2type !== "nul") {
|
||||||
var msg2 = RED.util.cloneMessage(msg);
|
var msg2 = RED.util.cloneMessage(msg);
|
||||||
if (node.op2type === "flow" || node.op2type === "global") {
|
if (node.op2type === "flow" || node.op2type === "global") {
|
||||||
node.topics[topic].m2 = RED.util.evaluateNodeProperty(node.op2,node.op2type,node,msg);
|
node.topics[topic].m2 = RED.util.evaluateNodeProperty(node.op2,node.op2type,node,msg);
|
||||||
}
|
}
|
||||||
|
if (node.topics[topic] !== undefined) {
|
||||||
msg2.payload = node.topics[topic].m2;
|
msg2.payload = node.topics[topic].m2;
|
||||||
node.send(msg2);
|
node.send(msg2);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
delete node.topics[topic];
|
delete node.topics[topic];
|
||||||
node.status({});
|
node.status({});
|
||||||
}, node.duration);
|
}, node.duration);
|
||||||
|
@ -282,7 +282,7 @@ describe('trigger node', function() {
|
|||||||
n1.emit("input", {payload:1,topic:"A"});
|
n1.emit("input", {payload:1,topic:"A"});
|
||||||
n1.emit("input", {payload:2,topic:"B"});
|
n1.emit("input", {payload:2,topic:"B"});
|
||||||
n1.emit("input", {payload:3,topic:"C"});
|
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 );
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user