Can't think of a good place to add a code comment. I will explain here.

We register a callback for tick() on "intf-event". This event occurs several times a second when input is active (playing or paused) thus tick() will be called several times a second. tick() immediately checks if enough time has passed to be worth sending a packet (controlled by update_rate), for the client it checks if enough time has passed to be worth trying to receive a packet. If enough time has passed the packet is sent and everybody is happy.

The advantage of this method is that we don't need to call any native "sleep" functions, we are not wasting CPU by having it sit and spin, we are also not blocking so if the server pauses, for example, "playing_changed()" will still be called.

Here is an analogy for call backs:
- Blocking = you are waiting for a parcel so you constantly check if the postman is at the door
- Non-blocking (callback) = you get on with life and deal with the postman when he rings the bell

Hope this helps.