- Using io.emit, we can send a message to all connected clients.
- If we wanted to send a message to all the users in a particular room, we would use something like the following, where we say what room we are sending the message to and then use emit to set the event and message:
io.to('room').emit('event', 'message');
- To send the message to all users, except for the sender, we need to broadcast it:
socket.broadcast.emit('broadcast', 'my message');
- There are certain event names that we cannot use as a message because they have been restricted due to them having a special meaning to Socket.IO. These are error, connect, disconnect, disconnecting, newListener, removeListener, ping, and pong.
- Socket.IO is made up of a number of different ...