mirror of
https://github.com/m1k1o/neko.git
synced 2025-08-06 10:20:26 +02:00
webrtc unmount all events on disconnect.
This commit is contained in:
parent
af206457ab
commit
e958690e10
1 changed files with 28 additions and 5 deletions
|
@ -153,12 +153,35 @@ export class NekoWebRTC extends EventEmitter<NekoWebRTCEvents> {
|
|||
}
|
||||
|
||||
public disconnect() {
|
||||
try {
|
||||
this._peer!.close()
|
||||
} catch (err) {}
|
||||
if (typeof this._channel !== 'undefined') {
|
||||
// unmount all events
|
||||
this._channel.onerror = () => {}
|
||||
this._channel.onmessage = () => {}
|
||||
this._channel.onopen = () => {}
|
||||
this._channel.onclose = () => {}
|
||||
|
||||
try {
|
||||
this._channel.close()
|
||||
} catch (err) {}
|
||||
|
||||
this._channel = undefined
|
||||
}
|
||||
|
||||
if (typeof this._peer != 'undefined') {
|
||||
// unmount all events
|
||||
this._peer.onsignalingstatechange = () => {}
|
||||
this._peer.onicecandidate = () => {}
|
||||
this._peer.oniceconnectionstatechange = () => {}
|
||||
this._peer.ontrack = () => {}
|
||||
this._peer.ondatachannel = () => {}
|
||||
|
||||
try {
|
||||
this._peer.close()
|
||||
} catch (err) {}
|
||||
|
||||
this._peer = undefined
|
||||
}
|
||||
|
||||
this._peer = undefined
|
||||
this._channel = undefined
|
||||
this._state = 'disconnected'
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue