Michelle Bu 11 жил өмнө
parent
commit
766442d281
1 өөрчлөгдсөн 4 нэмэгдсэн , 3 устгасан
  1. 4 3
      lib/server.js

+ 4 - 3
lib/server.js

@@ -78,9 +78,6 @@ PeerServer.prototype._initializeWSS = function() {
             self._clients[key][id] = { token: token, ip: ip };
             self._ips[ip]++;
             socket.send(JSON.stringify({ type: 'OPEN' }));
-            // We're going to emit here, because for XHR we don't *know* when someone
-            // disconnects.
-            self.emit('connection', id);
           }
           self._configureWS(socket, key, id, token);
         } else {
@@ -141,6 +138,10 @@ PeerServer.prototype._configureWS = function(socket, key, id, token) {
       throw e;
     }
   });
+
+  // We're going to emit here, because for XHR we don't *know* when someone
+  // disconnects.
+  this.emit('connection', id);
 };