March 2018
Intermediate to advanced
592 pages
13h 44m
English
The first step in the process is going to be to add a user to the list when they join a chatroom. We can do that right after our call to socket.join. I'm going to remove the old comments, although you can choose to keep yours around if you find they are a good reference. Just below socket.join, we're going to call users.addUser, adding our brand new user, and we need to pass in those three pieces of information, the socket ID, socket.id is where that's stored, the name, that's on params.name, and finally we're going to go ahead and pass in the room name, params.room:
socket.join(params.room);users.addUser(socket.id, params.name, params.room);
Now as you notice this code is not supposed to run if there is a validation ...