From f81161b2d571b881fe291ec15401528796e1e9ab Mon Sep 17 00:00:00 2001
From: "p.vanderwilt"
Date: Tue, 22 Jul 2025 12:20:29 +0200
Subject: [PATCH] Process output using tick function rather than clock message
---
src/nodeClass.js | 19 ++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)
diff --git a/src/nodeClass.js b/src/nodeClass.js
index 97ec545..637ec5b 100644
--- a/src/nodeClass.js
+++ b/src/nodeClass.js
@@ -21,6 +21,8 @@ class nodeClass {
this._attachInputHandler();
this._registerChild();
+ this._startTickLoop();
+ this._attachCloseHandler();
}
/**
@@ -32,7 +34,6 @@ class nodeClass {
switch (msg.topic) {
case "clock":
this.source.updateState(msg.timestamp);
- send([this.source.getEffluent, null, null]);
send([msg, null, null]);
break;
case "Fluent":
@@ -137,6 +138,22 @@ class nodeClass {
this.node.source = this.source;
}
+ _startTickLoop() {
+ setTimeout(() => {
+ this._tickInterval = setInterval(() => this._tick(), 1000);
+ }, 1000);
+ }
+
+ _tick(){
+ this.node.send([this.source.getEffluent, null, null]);
+ }
+
+ _attachCloseHandler() {
+ this.node.on('close', (done) => {
+ clearInterval(this._tickInterval);
+ done();
+ });
+ }
}
module.exports = nodeClass;
\ No newline at end of file