As we discussed in the last chapter, we have our socket join
listener but the problem is that the information inside the listener. It gets lost once the callback is complete, things like the username and the room name, they are not persisted anywhere. We're going to need that information to complete our event listeners. createMessage
is going to need to know the user's name as well as the room name to send that message to the specific room, and same is the case with createLocationMessage
. We'll discuss that in this chapter.
We'll start with learning the ES6 class syntax and using it in creating users
class and some other methods. We'll also see wiring up the users list, updating the people list when any user joins or leaves the chat. We'll also look into sending messages to a specific room and not to all the users.