소스 검색

Cancel keep alive on join room

RobinLinus 6 년 전
부모
커밋
61697d3abc
1개의 변경된 파일4개의 추가작업 그리고 1개의 파일을 삭제
  1. 4 1
      server/index.js

+ 4 - 1
server/index.js

@@ -53,11 +53,13 @@ class SnapdropServer {
     }
 
     _joinRoom(peer) {
-        this._cancelKeepAlive(peer);
         // if room doesn't exist, create it
         if (!this._rooms[peer.ip]) {
             this._rooms[peer.ip] = {};
         }
+        if (this._rooms[peer.ip][peer.id]) {
+            this._cancelKeepAlive(this._rooms[peer.ip][peer.id]);
+        }
 
         // console.log(peer.id, ' joined the room', peer.ip);
         // notify all other peers
@@ -128,6 +130,7 @@ class SnapdropServer {
                 type: 'ping'
             });
         }
+        this._cancelKeepAlive(peer);
         peer.timerId = setTimeout(() => this._keepAlive(peer), timeout);
     }