mirror of
https://github.com/sbrl/Nibriboard.git
synced 2018-01-10 21:33:49 +00:00
[client] Fix phantom disconnect on page load
This commit is contained in:
parent
41e6b46311
commit
eeee26e720
1 changed files with 9 additions and 0 deletions
|
@ -15,7 +15,12 @@ class RippleLink extends EventEmitter
|
|||
this.settings = this.boardWindow.settings;
|
||||
|
||||
// Create the websocket and commect to the server
|
||||
|
||||
// Whether the link ot the nibri server is open or not
|
||||
this.linkOpen = false;
|
||||
// The underlying websocket
|
||||
this.websocket = new WebSocket(this.socketUrl, [ this.settings.WebsocketProtocol ]);
|
||||
// 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));
|
||||
|
@ -32,11 +37,15 @@ class RippleLink extends EventEmitter
|
|||
|
||||
handleConnection(event) {
|
||||
console.info("[ripple link] Established connection successfully.");
|
||||
this.linkOpen = true;
|
||||
// Tell everyone about it
|
||||
this.emit("connect", event);
|
||||
}
|
||||
|
||||
handleDisconnection(event) {
|
||||
// If the link was already down, then ignore this phantom disconnection
|
||||
if(!this.linkOpen)
|
||||
return;
|
||||
console.error("[ripple link] Lost connection.");
|
||||
this.boardWindow.interface.setConnectedStatus(false);
|
||||
|
||||
|
|
Loading…
Reference in a new issue