-
Notifications
You must be signed in to change notification settings - Fork 113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ping-pong implementation that handles stale connections. #239
Conversation
e6f047d
to
2f9f180
Compare
f22f55e
to
242fa79
Compare
242fa79
to
ae484a7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is really great, I like how we can use the same code for client & server. I left two minor comments but they're not really blockers.
@@ -252,6 +255,7 @@ data Connection = Connection | |||
{ connectionOptions :: !ConnectionOptions | |||
, connectionType :: !ConnectionType | |||
, connectionProtocol :: !Protocol | |||
, connectionHeartbeat :: !(MVar ()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would add a comment to the field explaining how this is used (or refer to the PingPong module).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done :)
-- for example N/2. | ||
data PingPongOptions = PingPongOptions { | ||
pingInterval :: Int, -- ^ Interval in seconds | ||
pongTimeout :: Int, -- ^ Timeout in seconds |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I only noticed this because of the comment on the other PR; but I guess it would be more consistent if the library uses microseconds for time everywhere rather than mixed units?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given that the other Ping utilities use seconds, maybe it's better we just use seconds for the connection timeout as well. I'll add it to the other PR.
Because the Server used only pong implementation it's not possible to keep backwards compatibility with the new implementation that also does pinging.
ae484a7
to
24d7f56
Compare
Because the Server used only pong implementation it's not possible to keep backwards compatibility with the new implementation that also does pinging.
Fixes #159
cc @jaspervdj