1
0
Fork 0
mirror of https://github.com/sbrl/Nibriboard.git synced 2018-01-10 21:33:49 +00:00

[client] Tentatively fix reconnect-on-refresh issue by removing the websocket close handler when disconnecting in beforeunload.

This commit is contained in:
Starbeamrainbowlabs 2017-10-03 19:24:06 +01:00
parent 7a6d758e92
commit b55ba73c57
2 changed files with 5 additions and 2 deletions

View file

@ -23,7 +23,8 @@ class RippleLink extends EventEmitter
// Attach some event listeners // Attach some event listeners
this.websocket.addEventListener("open", this.handleConnection.bind(this)); this.websocket.addEventListener("open", this.handleConnection.bind(this));
this.websocket.addEventListener("message", this.handleMessage.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 // Respond to heartbeats from the server
this.on("Heartbeat", this.handleHeartbeat.bind(this)); this.on("Heartbeat", this.handleHeartbeat.bind(this));
@ -31,6 +32,8 @@ class RippleLink extends EventEmitter
// Close the socket correctly // Close the socket correctly
window.addEventListener("beforeunload", (function(event) { window.addEventListener("beforeunload", (function(event) {
// Remove the event listener to avoid issues on refresh
this.websocket.removeEventListener("close", closeHandler);
this.websocket.close(); this.websocket.close();
}).bind(this)); }).bind(this));
} }

View file

@ -91,7 +91,7 @@ namespace Nibriboard.RippleSpace
public DateTime TimeLastAccessed { get; private set; } = DateTime.Now; public DateTime TimeLastAccessed { get; private set; } = DateTime.Now;
/// <summary> /// <summary>
/// Whether this <see cref="T:Nibriboard.RippleSpace.Chunk"/> is primary chunk. /// Whether this <see cref="Chunk"/> is a primary chunk.
/// Primary chunks are always loaded. /// Primary chunks are always loaded.
/// </summary> /// </summary>
[JsonProperty] [JsonProperty]