You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As seen with the echo server example, https://docs.python.org/3/library/asyncio-protocol.html#echo-server - I would like to be able to use a subclass of WebSocket*Protocol (in my case the server) and override methods similar (perhaps not the same) as those to implement desired functionality. I could make a thin wrapper class that emulates this if it would be considered useful.
The text was updated successfully, but these errors were encountered:
If that doesn't answer your question, maybe you could show me what you're trying to do, what results you get, and explain what results you would expect?
Otherwise, is this an issue with the documentation?
If I understand correctly, you would like to be able to handle incoming websocket messages through callbacks rather than by defining a handler.
Considering the design of the API and the current implementation, this is rather hard. I would need an incremental parser, which I haven't implemented. Writing everything with coroutines makes the code much simpler (as you might expect — that's pretty much the point of asyncio).
Choosing coroutines over callbacks was an early design decision of the project. Later I realized it would prevent some use cases, but that's the way I wanted to write it and it don't see any useful way to refactor it.
Your best chance is to write a websocket handler that reads messages in a loop and calls the callback whenever it gets a message, which is what you did. I don't understand entirely why you have so much code around, because I don't know the context, but that was the right idea if you want to use my library.
Maybe you should use another library, there's a few hanging around.
As seen with the echo server example, https://docs.python.org/3/library/asyncio-protocol.html#echo-server - I would like to be able to use a subclass of WebSocket*Protocol (in my case the server) and override methods similar (perhaps not the same) as those to implement desired functionality. I could make a thin wrapper class that emulates this if it would be considered useful.
The text was updated successfully, but these errors were encountered: