I'm creating a script that uses a websocket. It will constantly process many frames all the time. My script will collect all the data from those frames, and periodically perform some calculations on that data it maintains. I had it working so my calculations would run every second, and my script seemed to keep up with the data collection ok. However, that doesn't seem like the best method.
I think ideally, my calculations would run every time all frames are collected and the websocket is idle, even if just for a few milliseconds. That way I know my calculations are using the most current data received, and my 1 second timer won't be blocking the websocket from reading the frames it has already received. Then I would also know my calculations are run as frequently as possible rather than a fixed 1 second timer.
I can't seem to find a websocket module that has an idle event. It doesn't even need to use events. Even something with a function that will process all received frames when called and return when completed should work fine. Then I could just put that in a loop with my calculations. I can't seem to find anything like that though. Thanks monks in advance for any help.