Answer the question
In order to leave comments, you need to log in
socket.io how to use rooms?
There is a channel id that broadcasts messages.
There are users.
How to create a room for this channel?
And how to subscribe a user to receive messages from this channel/room?
How to send messages to a room so that they refer to everyone who is subscribed to it?
Answer the question
In order to leave comments, you need to log in
socket.join('room3'); // подключить клиента к комнате room3
const clients = io.sockets.adapter.rooms['room3'];
const numClients = (typeof clients !== 'undefined') ? Object.keys(clients.sockets).length : 0;
io.in('room3').emit('user_join_chat', socket.id);
socket.io/docs/rooms-and-namespaces
Or what exactly is the question?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question