mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
disconnect on connection state change.
This commit is contained in:
parent
90648c83a7
commit
701ba4f233
@ -95,7 +95,17 @@ export class NekoWebRTC extends EventEmitter<NekoWebRTCEvents> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this._peer.onconnectionstatechange = (event) => {
|
this._peer.onconnectionstatechange = (event) => {
|
||||||
this._log.debug(`peer connection state changed: ${this._peer!.connectionState}`)
|
const state = this._peer!.connectionState
|
||||||
|
this._log.debug(`peer connection state changed: ${state}`)
|
||||||
|
|
||||||
|
switch (state) {
|
||||||
|
// Chrome sends failed state change only for connectionState and not iceConnectionState, and firefox
|
||||||
|
// does not support connectionState at all.
|
||||||
|
case 'closed':
|
||||||
|
case 'failed':
|
||||||
|
this.onDisconnected(new Error('peer ' + state))
|
||||||
|
break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this._peer.oniceconnectionstatechange = (event) => {
|
this._peer.oniceconnectionstatechange = (event) => {
|
||||||
@ -121,6 +131,7 @@ export class NekoWebRTC extends EventEmitter<NekoWebRTCEvents> {
|
|||||||
// The closed signaling state has been deprecated in favor of the closed iceConnectionState.
|
// The closed signaling state has been deprecated in favor of the closed iceConnectionState.
|
||||||
// We are watching for it here to add a bit of backward compatibility.
|
// We are watching for it here to add a bit of backward compatibility.
|
||||||
case 'closed':
|
case 'closed':
|
||||||
|
case 'failed':
|
||||||
this.onDisconnected(new Error('peer ' + state))
|
this.onDisconnected(new Error('peer ' + state))
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user