From b55ba73c577651279a618e658054ab2603652343 Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Tue, 3 Oct 2017 19:24:06 +0100 Subject: [PATCH] [client] Tentatively fix reconnect-on-refresh issue by removing the websocket close handler when disconnecting in beforeunload. --- Nibriboard/ClientFiles/RippleLink.js | 5 ++++- Nibriboard/RippleSpace/Chunk.cs | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Nibriboard/ClientFiles/RippleLink.js b/Nibriboard/ClientFiles/RippleLink.js index adced9b..a06c845 100644 --- a/Nibriboard/ClientFiles/RippleLink.js +++ b/Nibriboard/ClientFiles/RippleLink.js @@ -23,7 +23,8 @@ class RippleLink extends EventEmitter // Attach some event listeners this.websocket.addEventListener("open", this.handleConnection.bind(this)); this.websocket.addEventListener("message", this.handleMessage.bind(this)); - this.websocket.addEventListener("close", this.handleDisconnection.bind(this)); + let closeHandler = this.handleDisconnection.bind(this); + this.websocket.addEventListener("close", closeHandler); // Respond to heartbeats from the server this.on("Heartbeat", this.handleHeartbeat.bind(this)); @@ -31,6 +32,8 @@ class RippleLink extends EventEmitter // Close the socket correctly window.addEventListener("beforeunload", (function(event) { + // Remove the event listener to avoid issues on refresh + this.websocket.removeEventListener("close", closeHandler); this.websocket.close(); }).bind(this)); } diff --git a/Nibriboard/RippleSpace/Chunk.cs b/Nibriboard/RippleSpace/Chunk.cs index 261d9e9..66b80b7 100644 --- a/Nibriboard/RippleSpace/Chunk.cs +++ b/Nibriboard/RippleSpace/Chunk.cs @@ -91,7 +91,7 @@ namespace Nibriboard.RippleSpace public DateTime TimeLastAccessed { get; private set; } = DateTime.Now; /// - /// Whether this is primary chunk. + /// Whether this is a primary chunk. /// Primary chunks are always loaded. /// [JsonProperty]