python-trio / trio-websocket

WebSocket client and server implementation for Python Trio
MIT License
70 stars 26 forks source link

Improve ping v2 #58

Closed mehaase closed 6 years ago

mehaase commented 6 years ago

This PR implements ping/pong behavior similar to aaugustin's websocket library. A call to ping() waits for a response with the same payload. (An exception is raised if the payload matches a ping that's already in flight.) A payload is randomly generated if omitted by the caller. Add a new pong() method that can be used for sending an unsolicited pong.

mehaase commented 6 years ago

John approved this review, and Nathaniel likes this design too, so I think we all agree that this branch can be merged. However, this was branched from example_client_handle_close_v2, so I can't merge it until we finalize #55.

belm0 commented 6 years ago

Well, the intermediate PR could just be squashed if we could agree on addition here.

What I'd like to see:

mehaase commented 6 years ago

Sure, I can rebase this PR, but since they both touch the example client it would take a few minutes and I'd rather hold off if we can the other PR figured out soon. I'll address your comments in that thread.

belm0 commented 6 years ago

I mean no rebase needed, just make the incremental change here and use squash merge, and close the other PR.

Also I realized that heartbeat function can remain as is, just call with timeout inf.