Fix beforeunload on iphone
This commit is contained in:
parent
728aabd449
commit
4cf2beda90
1 changed files with 2 additions and 2 deletions
|
@ -3,11 +3,11 @@ class ServerConnection {
|
||||||
constructor() {
|
constructor() {
|
||||||
this._connect();
|
this._connect();
|
||||||
Events.on('beforeunload', e => this._disconnect(), false);
|
Events.on('beforeunload', e => this._disconnect(), false);
|
||||||
Events.on('pageshow', e => this._connect(), false);
|
Events.on('pagehide', e => this._disconnect(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
_connect() {
|
_connect() {
|
||||||
if (this._isConnected()) return
|
if (this._isConnected()) return;
|
||||||
const ws = new WebSocket(this._endpoint());
|
const ws = new WebSocket(this._endpoint());
|
||||||
ws.binaryType = 'arraybuffer';
|
ws.binaryType = 'arraybuffer';
|
||||||
ws.onopen = e => console.log('WS: server connected');
|
ws.onopen = e => console.log('WS: server connected');
|
||||||
|
|
Loading…
Reference in a new issue