What I basically need is that I want to fire the disconnect function when someone exits the room, so that I can broadcast that N has left the room. But sadly, it doesn't fire. What am I doing wrong here?
Here's the code:
socket.on('disconnect',function () {
var bster = storage.getRoomUsers(data1.rid);
var phold;
for(bstee in bster) {
phold = bster[bstee];
suck[phold].emit('discon',datauser);
}
console.log("USERDISCON");
});
Basically, I want the above events to fire when a client closes his window, but it seems that when I close it, nothing happens. The console window doesn't even show that "USERDISCON" text. What's wrong here?