Cancel keep alive on join room

This commit is contained in:
RobinLinus 2018-09-21 20:25:54 +02:00
parent e71564a97c
commit 1d9581632f

View file

@ -11,7 +11,6 @@ class SnapdropServer {
this._wss.on('headers', (headers, response) => this._onHeaders(headers, response)); this._wss.on('headers', (headers, response) => this._onHeaders(headers, response));
this._rooms = {}; this._rooms = {};
this._timerID = 0;
console.log('Snapdrop is running on port', port); console.log('Snapdrop is running on port', port);
} }
@ -119,6 +118,7 @@ class SnapdropServer {
} }
_keepAlive(peer) { _keepAlive(peer) {
this._cancelKeepAlive(peer);
var timeout = 10000; var timeout = 10000;
if (!peer.lastBeat) { if (!peer.lastBeat) {
peer.lastBeat = Date.now(); peer.lastBeat = Date.now();
@ -130,7 +130,6 @@ class SnapdropServer {
this._send(peer, { type: 'ping' }); this._send(peer, { type: 'ping' });
this._cancelKeepAlive(peer);
peer.timerId = setTimeout(() => this._keepAlive(peer), timeout); peer.timerId = setTimeout(() => this._keepAlive(peer), timeout);
} }