Riorganizzato in cartelle e aggiunto tcp
This commit is contained in:
1 parent
d97866933e
commit
2ea5fe3063
11 files changed
+1584
-14
No files matched your search
@@ -0,0 +1,27 @@
|
||||
|
||||
module.exports = function (RED) {
|
||||
"use strict";
|
||||
|
||||
function XMPPServerNode(n) {
|
||||
RED.nodes.createNode(this, n);
|
||||
this.delay_msec = n.delay;
|
||||
//this.by_value = n.by_value;
|
||||
this.recv = new Map();
|
||||
this.on("input", msg => {
|
||||
let msg_json = JSON.stringify(msg.payload);
|
||||
let now = new Date();
|
||||
for (let [key, val] of this.recv) {
|
||||
if ((now.getTime() - val.getTime()) > this.delay_msec) {
|
||||
this.recv.delete(key);
|
||||
}
|
||||
}
|
||||
if (!this.recv.has(msg_json)) {
|
||||
this.send(msg);
|
||||
this.recv.set(msg_json, now);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
RED.nodes.registerType("my-debounce", XMPPServerNode);
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user