From 2a50c716b1776285863f9752bf8ccf39fc10c888 Mon Sep 17 00:00:00 2001 From: Mitchell McCaffrey Date: Tue, 27 Oct 2020 13:42:23 +1100 Subject: [PATCH] Testing reconnecting on peer error --- src/network/Session.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/network/Session.js b/src/network/Session.js index 0978a4f..4ab847f 100644 --- a/src/network/Session.js +++ b/src/network/Session.js @@ -173,12 +173,19 @@ class Session extends EventEmitter { function handleClose() { this.emit("disconnect", { peer }); + console.log("CLOSE", peer); peer.connection.destroy(); this.peers = omit(this.peers, [peer.id]); } function handleError(error) { + logError(error); + peer.connection.destroy(); this.emit("error", { peer, error }); + this.emit("disconnected"); + if (this._partyId) { + this.joinParty(this._partyId, this._password); + } } peer.connection.on("signal", handleSignal.bind(this)); @@ -193,6 +200,10 @@ class Session extends EventEmitter { } catch (error) { logError(error); this.emit("error", { error }); + this.emit("disconnected"); + if (this._partyId) { + this.joinParty(this._partyId, this._password); + } } }