koa-websocket icon indicating copy to clipboard operation
koa-websocket copied to clipboard

Room management

Open hAz4rd0uS opened this issue 6 years ago • 1 comments

Hi,

I can't find any code in sources nor attribute in ctx.websocket object when logging it in the console related to room management, how to broadcast messages to listed sockets only ?

There's nothing in your example.

Thanks in advance.

hAz4rd0uS avatar Oct 18 '18 15:10 hAz4rd0uS

Hi,

I know this is very late, however rooms and channels are not part of the websockets. Instead, they are part of the WS libraries (like socket.io).

If you want rooms, you basically have to add an array to the socket object and add/remove rooms from it (you can implement that in any way you want).

For sending to specific rooms, create a separate function, which will filter out sockets that belong to the specified room and send the message only to those sockets.

combustpizza avatar Sep 16 '19 09:09 combustpizza