socketio / socket.io-redis-adapter

Adapter to enable broadcasting of events to multiple separate socket.io server nodes.
https://socket.io/docs/v4/redis-adapter/
MIT License
2.74k stars 487 forks source link

Suggestion: Make it possible to access sockets in different nodes without BroadCastOperator #548

Open knixer opened 2 months ago

knixer commented 2 months ago

Make it possible to access a socket in a different node without broadcasting. I cant use ack:s when emitting from a socket that I got from

const sockets  = io.of(namespace).fetchSockets()
const socket = sockets.find(socket => socket.id === recipientSocketId) 
socket.emit("path", data,  (ack) => {data})

or io.of(namespace).to(recipientSocketId).emit("path", data, (ack) => {data})

The error message I get is "Callbacks are not supported when broadcasting at BroadcastOperator.emit"

darrachequesne commented 2 months ago

Hi!

Which version of socket.io are you using? Callbacks when broadcasting are supported since version 4.5.0: https://socket.io/docs/v4/changelog/4.5.0#broadcast-and-expect-multiple-acknowledgements

The redis adapter does too: https://socket.io/docs/v4/redis-adapter/#supported-features