diff --git a/public/scripts/network.js b/public/scripts/network.js index d993d6c..b3183a3 100644 --- a/public/scripts/network.js +++ b/public/scripts/network.js @@ -21,13 +21,12 @@ class ServerConnection { ws.onclose = _ => this._onDisconnect(); ws.onerror = e => this._onError(e); this._socket = ws; - - Events.on('force-disconnect', this._onForceDisconnect); + Events.on('reconnect', this._reconnect); } _onMessage(msg) { msg = JSON.parse(msg); - console.log('WS:', msg); + if (msg.type !== 'ping') console.log('WS:', msg); switch (msg.type) { case 'peers': Events.fire('peers', msg.peers); @@ -79,11 +78,6 @@ class ServerConnection { Events.fire('disconnect'); } - _onForceDisconnect() { - document.cookie = "peerid=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;"; - this._connect(); - } - _onVisibilityChange() { if (document.hidden) return; this._connect(); @@ -105,7 +99,7 @@ class ServerConnection { _onError(e) { console.error(e); - this._onForceDisconnect(); + this._connect(); } } @@ -353,7 +347,7 @@ class RTCPeer extends Peer { switch (this._conn.iceConnectionState) { case 'failed': console.error('ICE Gathering failed'); - Events.fire('force-disconnect'); + Events.fire('reconnect'); break; default: console.log('ICE Gathering', this._conn.iceConnectionState); diff --git a/public/scripts/ui.js b/public/scripts/ui.js index 69af888..61d183c 100644 --- a/public/scripts/ui.js +++ b/public/scripts/ui.js @@ -9,6 +9,9 @@ window.iOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream; Events.on('display-name', e => { const me = e.detail.message; const $displayName = $('displayName') + if ($displayName.textContent !== '') { + Events.fire('notify-user', 'Your name has changed.'); + } $displayName.textContent = 'You are known as ' + me.displayName; $displayName.title = me.deviceName; }); @@ -65,6 +68,7 @@ class PeersUI { _clearPeers() { const $peers = $$('x-peers').innerHTML = ''; Object.keys(this.peers).forEach(peerId => delete this.peers[peerId]); + setTimeout(e => window.animateBackground(true), 1750); // Start animation again } _onPaste(e) {