title: connect event not firing for second client
body: <p><strong>EDIT:</strong> I got it working by replacing localhost with my public IP and then port forwarding port 4200 to my computer.</p>
  
  <p><strong>EDIT 2:</strong> That fix it some of the time. Updating socket.io fixed a bit more. I've now set up a timer that runs <code>onConnect</code> after 5 seconds if it isn't called on its own (bad hack, I know, but the only way that can ensure that it is called).</p>
  
  <p><strong>EDIT 3:</strong> Nope, I think it was because I was running the phaser state before onConnect had a chance to run. I've now changed it so that the phaser state is called from within onConnect.</p>
  
  <p>I'm working on a small multiplayer platforming game but have run into issues with networking. The first client to connect works perfectly fine: it connects, creates a player, updates with server, etc. The second client however, according to the server, connects but the local onConnect function is never called. And what's weirder is that very occasionally it decides it wants to work correctly - connect event fires for both clients and I have two players running about.</p>
  
  <p><strong>Client</strong></p>
  
  <pre><code>var socket = io.connect("http://localhost:4200");
  ...
  function setEventHandlers(localPlayer){
      player = localPlayer;
  
      console.log("Event handlers set");
  
      socket.on("connect", onConnect);
      socket.on("disconnect", onDisconnect);
      socket.on("new player", onNewPlayer);
      socket.on("move player", onMovePlayer);
      socket.on("remove player", onRemovePlayer);
  }
  
  function onConnect(){
      console.log("Connected to server");
  
      // Send local player to server
      socket.emit("new player", player.getSendableObject());
  }
  </code></pre>
  
  <p><strong>Server</strong></p>
  
  <pre><code>socket = io.listen(PORT);
  ...
  function setEventHandlers(){
      socket.sockets.on("connection", onConnect);
  }
  
  function onConnect(client){
      util.log("Client connected: " + client.id);
  
      client.on("disconnect", onDisconnect);
      client.on("new player", onNewPlayer);
      client.on("move player", onMovePlayer);
  }
  </code></pre>