how to implement a heartbeat? #20

Closed
scottpersinger opened this Issue Jul 12, 2012 · 1 comment

2 participants

@scottpersinger

I'd like to publish heartbeat messages on a set interval (like every 3 seconds), but at least using Greenlet's doesn't seem to work (nor gevent.core.timer). Looks like conn.read_frames() on connection blocks any other greenlet running. Any advice on getting something to run on a timeout?

@awestendorf
Agora Games member

The connection constructor takes a heartbeat= kwarg which you can use to enable heartbeats. If heartbeats are enabled then read_frames() will use that as the socket timeout. Additional kwargs are documented in the Functional Specifications section of the documentation.

https://github.com/agoragames/haigha/blob/master/DOCUMENTATION.rst
https://github.com/agoragames/haigha/blob/master/haigha/connection.py#L339

For blocking sockets a future update will include an argument to read_frames() to allow the caller discrete control over socket timeouts.

@awestendorf awestendorf closed this Nov 5, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment