I have a process that sends me data packets at intervals, and I need to control this flow depending on the time packets arrived, etc. At some point, I also close the thread and the process.
Right now, I am using a set of timers for this, but I hope I can do it with rxjs as it seems very suitable for this kind of thing. So far I have not had much success.
Problem
A thread should send me packets at regular intervals, but it usually rejects very often and sometimes gets stuck.
I want to close the stream at some point under the following conditions:
- If I need to send the first package more than
startDelay . - After sending the first packet, if there is a pause longer than
middleDelay between two packets. - After a specified period of time
maxChannelTime .
When I am about to close the stream for any of the above reasons, I first ask it to be closed politely so that it can do some cleaning. Sometimes it also sends me the final data packet during cleanup. But I want to wait more than cleanupTime to clean up and get the latest data before I close the stream and ignore any messages.
Development
I will create "threads" by wrapping the Observable event. I have no problem with this.
By "closing" the stream, I want to say that the process has stopped emitting data and, possibly, closing (i.e., dying).
Gregros
source share