fix reconnection _onChannelClosed()
This commit is contained in:
commit
6c4b7b893a
1 changed files with 4 additions and 3 deletions
|
@ -79,7 +79,7 @@ class ServerConnection {
|
||||||
console.log('WS: server disconnected');
|
console.log('WS: server disconnected');
|
||||||
Events.fire('notify-user', 'Connection lost. Retry in 5 seconds...');
|
Events.fire('notify-user', 'Connection lost. Retry in 5 seconds...');
|
||||||
clearTimeout(this._reconnectTimer);
|
clearTimeout(this._reconnectTimer);
|
||||||
this._reconnectTimer = setTimeout(_ => this._connect(), 5000);
|
this._reconnectTimer = setTimeout(this._connect, 5000);
|
||||||
Events.fire('disconnect');
|
Events.fire('disconnect');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -322,14 +322,14 @@ class RTCPeer extends Peer {
|
||||||
const channel = event.channel || event.target;
|
const channel = event.channel || event.target;
|
||||||
channel.binaryType = 'arraybuffer';
|
channel.binaryType = 'arraybuffer';
|
||||||
channel.onmessage = e => this._onMessage(e.data);
|
channel.onmessage = e => this._onMessage(e.data);
|
||||||
channel.onclose = e => this._onChannelClosed();
|
channel.onclose = _ => this._onChannelClosed();
|
||||||
this._channel = channel;
|
this._channel = channel;
|
||||||
}
|
}
|
||||||
|
|
||||||
_onChannelClosed() {
|
_onChannelClosed() {
|
||||||
console.log('RTC: channel closed', this._peerId);
|
console.log('RTC: channel closed', this._peerId);
|
||||||
Events.fire('peer-disconnected', this._peerId);
|
Events.fire('peer-disconnected', this._peerId);
|
||||||
if (!this._isCaller || !this._conn) return;
|
if (!this._isCaller) return;
|
||||||
this._connect(this._peerId, true); // reopen the channel
|
this._connect(this._peerId, true); // reopen the channel
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -443,6 +443,7 @@ class PeersManager {
|
||||||
const peer = this.peers[peerId];
|
const peer = this.peers[peerId];
|
||||||
delete this.peers[peerId];
|
delete this.peers[peerId];
|
||||||
if (!peer || !peer._conn) return;
|
if (!peer || !peer._conn) return;
|
||||||
|
peer._channel.onclose = null;
|
||||||
peer._conn.close();
|
peer._conn.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue