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
Is your feature request related to a problem? Please describe.
Currently, Socketify uses a method of using the open, message, and close indicators to show parse the obvious. This makes it much harder to track and sustain a connection easily.
Describe the solution you'd like
I would like an implementation to something like what the WebSockets library has, and what most other libraries do:
This would be optional, and not required to use websockets. It'd also make it much easier to keep state if, per se, you're trying to make a chat app or another similar thing which requires state and easy DX.
else then all of that though, I'd just like to say that this project is really nice, I've always been looking for a fast Python websocket lib and I think this one is a first, I can't wait to see this library be production-ready!
The text was updated successfully, but these errors were encountered:
The current version basically is a 1-to-1 representation of uWS C++ WS, I will not change this, but I can add some helpers, adding an async/ASGI-like wrapper will add a ton of overhead, and socketify.py focus is performance. But I will consider adding an official helper.
Will be better, in general, using decorators or something similar to handle the websocket events and routes.
fromsocketifyimportAppapp=App()
ws=app.ws("/websocket", {
'compression': CompressOptions.SHARED_COMPRESSOR,
'max_payload_length': 16*1024*1024,
'idle_timeout': 12,
})
@ws.opendefws_open(ws):
print("A WebSocket got connected!")
ws.send("Hello World!", OpCode.TEXT)
@ws.messagedefws_message(ws, message, opcode):
print(message, opcode)
# Ok is false if backpressure was built up, wait for drainok=ws.send(message, opcode)
@ws.closedefws_message( ws, code, message):
print("WebSocket closed")
I will also add a decorator for something similar to what you proposed too, something similar to ASGI form of handling connections, will be overhead and I will measure it and add it to the docs and the user can decide if is worth it or not.
Is your feature request related to a problem? Please describe.
Currently, Socketify uses a method of using the
open
,message
, andclose
indicators to show parse the obvious. This makes it much harder to track and sustain a connection easily.Describe the solution you'd like
I would like an implementation to something like what the
WebSockets
library has, and what most other libraries do:This would be optional, and not required to use websockets. It'd also make it much easier to keep state if, per se, you're trying to make a chat app or another similar thing which requires state and easy DX.
else then all of that though, I'd just like to say that this project is really nice, I've always been looking for a fast Python websocket lib and I think this one is a first, I can't wait to see this library be production-ready!
The text was updated successfully, but these errors were encountered: