The consumer goes during the area id and we simply inform clients.leave() to take out current user phoning this method from a certain talk space.
Whenever a person joins a talk area, they are going to inform us towards place they wish to join together with the other person that is part of that chat place.
Note: We will see later that after we initiate a speak space we get all of the users involving that space inside the API feedback.
In my view: yet another thing we’re able to have inked here was actually when the individual directs in area number, we could generate a DB question to see the people in the talk space making all of them join if they’re on line right now (that’s, inside our consumers number).
Utilizing the otherUserId we filtration on our very own this.users range as well as the outcome that complement tend to be kept in userSockets collection.
You are thinking a€“ you can individual posses multiple presences when you look at the individual array? Better, contemplate a situation where the exact same consumer are logged in from both their own online application and mobile. It is going to build several plug connections for similar individual.
Next we map on userSockets . For every single items inside array we move they into this method: const socketConn = .sockets.connected(userInfo.socketId)
I am going to talking more about this .sockets.connected in quite. Exactly what this at first really does is-it ingests userInfo.socketId if in case they is available inside our plug connection, it is going to go back the bond, or else null . (more…)