Open
Description
Is your feature request related to a problem? Please describe.
In a multi-server scenario with a message queue such as redis or rabittmq, it is important to be able to send messages between servers.
That is why socket.io 4.1 introduced the serverSideEmit
function: dzad/socket.io@491a9a0. This seems to be missing from python-socketio though.
Ideally, parameters like room
or to
can limit the servers the message is sent to.
Describe the solution you'd like
A sio.server_side_emit(..., to=..., room=...)
function and self.server_side_emit(..., to=..., room=...)
method to do inter-server communication.
Describe alternatives you've considered
- adding clients between servers manually. This is not really feasible with dynamically scaled servers.
- configuring the client manager manually. This seems not feasible either.
Additional context
# server A
await sio.server_side_emit("hello", "world", room="test")
# server B
@sio.on("hello")
async def server_notifications(sid, message):
print(message) # should print "world" if server is in room "test"