I have been trying to create a multiplayer game in Nodejs which persists the number of users in a room into MongoDB. I have been having an issue, when a user joins the room, I save the room and its info using a method called "joinroom", and on the call back of the method I am supposed to know the number of users in the room so I can start the game, but I am unable to retrieve the users in a particular room when I try to get it in a call back. Please, I need help solving this issue.
var global = this;
socket.join('xxx');
global.JoinRoom(socket, data.sessionId,data.amount, function (match) {
setTimeout(function() {
// global.initializeGame('xxx',global.IO);
let c = global.IO.nsps['/'].adapter.rooms['xxx'];//.length;
c;
console.log(context);
}.bind(this), 1000);
});