mirror of
https://github.com/schlagmichdoch/PairDrop.git
synced 2025-04-20 07:05:05 -04:00
Fix notifications on android
This commit is contained in:
parent
36ec13d428
commit
e9eeea48e5
2 changed files with 20 additions and 6 deletions
|
@ -3,9 +3,11 @@ class ServerConnection {
|
|||
constructor() {
|
||||
this._connect();
|
||||
Events.on('beforeunload', e => this._disconnect(), false);
|
||||
Events.on('pageshow', e => this._connect(), false);
|
||||
}
|
||||
|
||||
_connect() {
|
||||
if (this._isConnected()) return
|
||||
const ws = new WebSocket(this._endpoint());
|
||||
ws.binaryType = 'arraybuffer';
|
||||
ws.onopen = e => console.log('WS: server connection opened');
|
||||
|
@ -16,6 +18,10 @@ class ServerConnection {
|
|||
clearTimeout(this._reconnectTimer);
|
||||
}
|
||||
|
||||
_isConnected(){
|
||||
return this._socket && this._socket.readyState === this._socket.OPEN;
|
||||
}
|
||||
|
||||
_onMessage(msg) {
|
||||
msg = JSON.parse(msg);
|
||||
console.log('WS:', msg);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue