snapdrop

A Progressive Web App for local file sharing
git clone http://git.hanabi.in/repos/snapdrop.git
Log | Files | Refs | README | LICENSE

commit 0ede41f8d5397e8b7beb62ba6abe2571296f4690
parent 1d9581632fe3a99c2068d8c0cece9345c9397cc8
Author: RobinLinus <robinlinus@users.noreply.github.com>
Date:   Fri, 21 Sep 2018 20:34:49 +0200

Cancel keep alive on join room

Diffstat:
Mserver/index.js | 11+++--------
1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/server/index.js b/server/index.js @@ -56,9 +56,6 @@ class SnapdropServer { 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 @@ -87,7 +84,7 @@ class SnapdropServer { _leaveRoom(peer) { if (!this._rooms[peer.ip] || !this._rooms[peer.ip][peer.id]) return; - this._cancelKeepAlive(peer); + this._cancelKeepAlive(this._rooms[peer.ip][peer.id]); // delete the peer delete this._rooms[peer.ip][peer.id]; @@ -112,9 +109,7 @@ class SnapdropServer { if (!peer) return console.error('undefined peer'); if (this._wss.readyState !== this._wss.OPEN) return console.error('Socket is closed'); message = JSON.stringify(message); - peer.socket.send(message, error => { - if (error) this._leaveRoom(peer); - }); + peer.socket.send(message, error => console.log(error)); } _keepAlive(peer) { @@ -134,7 +129,7 @@ class SnapdropServer { } _cancelKeepAlive(peer) { - if (peer.timerId) { + if (peer && peer.timerId) { clearTimeout(peer.timerId); } }