2

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.

...

Tyler McGinnis
  • 34,836
  • 16
  • 72
  • 77

1 Answers1

6

For future reference this was occurring because I was setting my angular controller in both my HTML and under my $routeProvider. This was then triggering everything twice.

Tyler McGinnis
  • 34,836
  • 16
  • 72
  • 77