mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
webrtc unmount all events on disconnect.
This commit is contained in:
parent
af206457ab
commit
e958690e10
@ -153,12 +153,35 @@ export class NekoWebRTC extends EventEmitter<NekoWebRTCEvents> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public disconnect() {
|
public disconnect() {
|
||||||
try {
|
if (typeof this._channel !== 'undefined') {
|
||||||
this._peer!.close()
|
// unmount all events
|
||||||
} catch (err) {}
|
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'
|
this._state = 'disconnected'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user