We're going to emit the event the client expects, updateUserList with the users array. If we don't emit the event, the client is never going to get the new list and we just updated the list, so we definitely want them to get a fresh copy. This means we want to emit an event to everyone in the chat room via io.to. We're going to pass in the room name and then we're going to call emit, emitting the event.
Now we can go ahead and fill out to first, we want to pass in the room name, params.room has that information, and next up we want to emit the event, the event name as we just defined over in chat.js is updateUserList. And the last thing we need to do is get the user list. We already have that, users.getUserList, passing in the name of the room we want to get the list for. Once again, params.room, that's going to be the only argument we pass in:
socket.join(params.room);
users.removeUser(socket.id);
users.addUser(socket.id, params.name, params.room);
io.to(params.room).emit('updateUserList', users.getUserList(params.room));
With this call in place, we should be able to actually view this over inside the Terminal.
I'm going to save this file, which is going to restart the server in the Terminal.