OSC trigger when no waiting messages?


I am working on a simple video player that is triggered by OSC commands. I want to be able to trigger an ‘idle’ video when OSC messages have not been received continuously for say 20 seconds.

Currently I have in update a

while( receiver.hasWaitingMessages() )
{ do stuff }

then I think I should have a

if (receiver.hasWaitingMessages() == false)
some kind of timer?
if reached end play vid

Or should that be a while loop?
What is the best way to implement the timer.

thanks for any help in advance


You can use ofGetSystemTime() to get the current time (in milliseconds).
In the while loop, put this into a variable (e.g. unsigned long lastKnownMessageTime) to update it continuously while you have messages waiting.
in the if clause, compare this value to the current time. if >20s, trigger the idle video.