From 4cf2beda9075d75e1efc6dca3dc0e390612882fd Mon Sep 17 00:00:00 2001 From: RobinLinus Date: Fri, 21 Sep 2018 19:49:16 +0200 Subject: [PATCH] Fix beforeunload on iphone --- client/scripts/network.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/scripts/network.js b/client/scripts/network.js index fdc1f8c..c986092 100644 --- a/client/scripts/network.js +++ b/client/scripts/network.js @@ -3,11 +3,11 @@ class ServerConnection { constructor() { this._connect(); Events.on('beforeunload', e => this._disconnect(), false); - Events.on('pageshow', e => this._connect(), false); + Events.on('pagehide', e => this._disconnect(), false); } _connect() { - if (this._isConnected()) return + if (this._isConnected()) return; const ws = new WebSocket(this._endpoint()); ws.binaryType = 'arraybuffer'; ws.onopen = e => console.log('WS: server connected');