-
-
Notifications
You must be signed in to change notification settings - Fork 540
add on_open() and on_close() methods, similar to tornado web socket implementation? #52
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
Comments
Perhaps there's a more straightforward solution for websockets, as its API uses coroutines rather than callbacks:
I want the API to stay explicit. Simply by reading the code, you must be able to follow what's going on. Introducing a callback-based API would break this design principle. Since I'm not familiar with Tornado's implementation of websockets, I may have failed to understand your idea. If so, could you clarify it? |
Hi, for now I'm using the:
and:
and they are doing the trick. I understand what you are saying re: callbacks and this makes sense. Thanks. |
Cool. Let me know if you think of improvements that are compatible with this philosophy. The library is rather simple at this time. Perhaps it could support some common use cases better :-) |
The try / finally style works nicely for the send method. It would be nice if something similar were possible with the receive method i.e. if recieve() could throw an error that allows for activating the 'graceful exit' code through error handling rather than checking for None types? |
Yes, I'm aware that this API creates some ugly code. Unfortunately I can't change it without breaking backwards-compatibility in a way that will affect everyone :-/ |
Would it be possible to add high-level on_open() and on_close() methods, similar to the web sockets implementation in Tornado, so that initialisation and cleanup can be performed?
The text was updated successfully, but these errors were encountered: