-
-
Notifications
You must be signed in to change notification settings - Fork 508
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 functions to allow proper subclassing of WebSocket*Protocol #32
Comments
I'm really sorry, but I don't get what changes you're asking for. Here's an example of subclassing WebSocketServerProtocol: 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? Thanks! |
Just after writing that comment, I noticed DCP-Project/minnow-prototype@1153086#diff-017639d70cd2c855d3f7c4ed46c3b2c2R362. 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: