Closed bboe closed 11 years ago
This is brilliant :)
Hmm, interesting! What if the bot is sitting in a room with nothing going on though? No pm's, no songs playing, and no on talking?
He will still receive the heartbeat requests from tt.fm, and then send an "updatePresence" on this event. (every ~12 seconds)
See this conversation : https://github.com/alaingilbert/Turntable-API/commit/7351302751fcae2a69d0b5c54eba46a4ef1d6f17#commitcomment-2089645 Really interesting !
Ah, cool, makes sense!
I did notice that my bot's websocket was closed after some amount of inactivity (at least an hour). I had noticed that, however, prior to this change. It appears to only affect a room where the bot is the only one in the room, and not djing. I'll look into it more over the next few days.
There is a super simple solution to the thread synchronization problem along with heartbeats. Given that the regular heartbeat request messages handle the case when the room is inactive, the only problem is when the room is active. The solution is to possibly trigger the heartbeat in response to any message type (if the last one was sent over 10 seconds before).
This gives a maximum interval of 22 seconds between heartbeats if the last activity was just before TT was about to send a heartbeat request message (assuming those come 12 seconds after the last activity).