mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Fix delay to not pass through .reset and .flush props consistently
to close #2349 (it used to not pass them through but did on initial message... now it doesn't)
This commit is contained in:
parent
e8ef476a6d
commit
a96d5096fe
@ -153,15 +153,26 @@ module.exports = function(RED) {
|
||||
}
|
||||
else if (node.pauseType === "rate") {
|
||||
node.on("input", function(msg) {
|
||||
if (msg.hasOwnProperty("reset")) {
|
||||
if (node.intervalID !== -1 ) {
|
||||
clearInterval(node.intervalID);
|
||||
node.intervalID = -1;
|
||||
}
|
||||
node.buffer = [];
|
||||
node.status({text:"reset"});
|
||||
return;
|
||||
}
|
||||
if (!node.drop) {
|
||||
var m = RED.util.cloneMessage(msg);
|
||||
delete m.flush;
|
||||
if (node.intervalID !== -1) {
|
||||
if (!msg.hasOwnProperty("flush")) {
|
||||
node.buffer.push(msg);
|
||||
//if (!msg.hasOwnProperty("flush")) {
|
||||
node.buffer.push(m);
|
||||
node.reportDepth();
|
||||
}
|
||||
//}
|
||||
}
|
||||
else {
|
||||
node.send(msg);
|
||||
node.send(m);
|
||||
node.reportDepth();
|
||||
node.intervalID = setInterval(function() {
|
||||
if (node.buffer.length === 0) {
|
||||
@ -174,6 +185,12 @@ module.exports = function(RED) {
|
||||
node.reportDepth();
|
||||
}, node.rate);
|
||||
}
|
||||
if (msg.hasOwnProperty("flush")) {
|
||||
while (node.buffer.length > 0) {
|
||||
node.send(node.buffer.shift());
|
||||
}
|
||||
node.status({});
|
||||
}
|
||||
}
|
||||
else {
|
||||
var timeSinceLast;
|
||||
@ -189,18 +206,6 @@ module.exports = function(RED) {
|
||||
node.send(msg);
|
||||
}
|
||||
}
|
||||
if (msg.hasOwnProperty("reset")) {
|
||||
clearInterval(node.intervalID);
|
||||
node.intervalID = -1;
|
||||
node.buffer = [];
|
||||
node.status({text:"reset"});
|
||||
}
|
||||
if (msg.hasOwnProperty("flush")) {
|
||||
while (node.buffer.length > 0) {
|
||||
node.send(node.buffer.shift());
|
||||
}
|
||||
node.status({});
|
||||
}
|
||||
});
|
||||
node.on("close", function() {
|
||||
clearInterval(node.intervalID);
|
||||
|
Loading…
Reference in New Issue
Block a user