March 2018
Intermediate to advanced
592 pages
13h 44m
English
In the last section, we set up an event listener on the server listening for that join event, and we did some validation. This at least makes sure we have the name and the room name, both of which are going to be required.
The real next step is to actually use the Socket.io library to join rooms, and this is not going to let us just join rooms but it's also going to give us a different set of methods. We can choose to emit to everybody connected to the server or just to people in specific rooms, and that's exactly what we're going to be doing. We want to emit chat messages just to other people who are also in the room.
Now in order to join, what you do is you call socket.join. The socket.join takes a string name, and we have ...