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

Support msg.nodeMessageBufferMaxLength

This commit is contained in:
Kazuhito Yokoi 2019-09-27 17:14:42 +09:00
parent eb301d0b9d
commit cc72f892f7

View File

@ -192,6 +192,18 @@ module.exports = function(RED) {
}
else if (node.pauseType === "rate") {
node.on("input", function(msg) {
if (msg.nodeMessageBufferMaxLength) {
node.debug("msg.nodeMessageBufferMaxLength = " + msg.nodeMessageBufferMaxLength);
if (msg.nodeMessageBufferMaxLength == 0) {
clearInterval(node.intervalID);
node.intervalID = -1;
node.buffer = [];
} else if (msg.nodeMessageBufferMaxLength < node.buffer.length) {
node.buffer = node.buffer.splice(msg.nodeMessageBufferMaxLength,
node.buffer.length - msg.nodeMessageBufferMaxLength);
}
_maxKeptMsgsCount = msg.nodeMessageBufferMaxLength;
}
if (!node.drop) {
if (node.intervalID !== -1) {
if (msg.hasOwnProperty("rate") && node.rate !== msg.rate) {