Closed hansSchall closed 5 months ago
This overlay for Receiver
will store the latest values for all sources for the specified time.
When any source changes, the merged values will be recomputed and changes within the output will be delivered to the user, by using the changed
event.
Usage:
const rec = new ReceiverMerge({
universes: [1],
reuseAddr: true,
timeout: 5000, // time the values will be stored before they are droped (assuming the source is down / has stopped sending data)
// ... more options (everything here will be passed to new Receiver({...}))
})
rec.on("changed", ({ addr, newValue: value }) => { console.log(addr, value) });
I have coded more detailed event objects; now they contain the senders cid and universe
merger.on("senderConnect", (ev: {cid: string, universe: number, firstPacket: Packet}) => {
...
});
merger.on("senderDisconnect", (ev: {cid: string, universe: number, lastPacket: Packet}) => {
...
});
additionally I've added default values to comply with ts-strict and converted SendersData to interface SendersData
There are two known bugs in the current version:
The first one affects the sender-id storage (This is already 90% fixed; has something to do with the key equality in a JS Map)
The other one appears if multiple universes are merged. In some circumstances the second universe is not merged.
I am working on a project, where up to 4 sources send to different universes on multiple priorities, so I can test the merging functionality carefully.
EDIT: they are all fixed by 2343cc6
Thanks again for making this PR. My original concerns from https://github.com/k-yle/sACN/pull/43#discussion_r845638359 still apply, but firstly: the performance of nodejs v21's EventEmitter is much better than node v13, and secondly: I'd rather merge this PR than have it sit around for any longer.
fixes #2