Reputation: 211
as mentioned in Socket.io Doc about rooms - i know that the server can move sockets to a specific room and send an event to that specific room
transfer socket to a room :
io.on('connection', (socket)=>{
socket.join('roomId');
});
emit event to sockets in that room :
io.to('roomId').emit('some event');
but i can't find a way that the server will listen to event coming only from a specific room, something like:
io.in('roomId').on('someevent',(socket)=>{....})
Upvotes: 2
Views: 2078
Reputation: 1450
Socket.io has no function for this. You will have to listen for everyone on that event and check the socket's joined rooms array.
Upvotes: 3