I've been having this issue for a while and can't figure it out. Basically I'm trying to trigger an Angular Modal if there is one person in the 'Room', and remove it when another person comes into that 'Room'. The problem I'm having is that the 'socket.in(room).emit('join', room)' is being fired twice on one connect which is freezing the modal. Any ideas would be greatly appreciated. I can post more code if I need to.
io.sockets.on('connection', function (socket) {
initcount += 1;
if (initcount % 2 === 1) {
roomcount += 1;
room = roomcount.toString();
roomList[room] = {user1: socket.id};
} else {
roomList[room].user2 = socket.id
}
socket.join(room);
socket['room'] = room;
socket.in(room).emit('join', room) //being triggered twice and freezing.
...