do not destroy WebRTC on WS disconnect.

This commit is contained in:
Miroslav Šedivý 2021-03-23 15:41:20 +01:00
parent 5178c4c36f
commit 80d229041a

View File

@ -404,14 +404,16 @@
this.websocket.on('connected', () => {
Vue.set(this.state.connection, 'websocket', 'connected')
this.events.emit('connection.websocket', 'connected')
if (!this.watching) {
this.webrtcConnect()
}
})
this.websocket.on('disconnected', () => {
Vue.set(this.state.connection, 'websocket', 'disconnected')
this.events.emit('connection.websocket', 'disconnected')
this.webrtc.disconnect()
this.clearState()
this.clearWebSocketState()
})
// webrtc
@ -481,22 +483,18 @@
let webrtcReconnect: any
this.webrtc.on('disconnected', () => {
Vue.set(this.state.connection.webrtc, 'status', 'disconnected')
Vue.set(this.state.connection.webrtc, 'stats', null)
Vue.set(this.state.connection.webrtc, 'video', null)
Vue.set(this.state.connection.webrtc, 'videos', [])
Vue.set(this.state.connection, 'type', 'none')
this.events.emit('connection.webrtc', 'disconnected')
this.clearWebRTCState()
if (!this._video) return
// destroy stream
// destroy video
if (this._video) {
if ('srcObject' in this._video) {
this._video.srcObject = null
} else {
// @ts-ignore
this._video.removeAttribute('src')
}
}
// reconnect WebRTC
if (this.connected) {
@ -581,8 +579,7 @@
}
}
clearState() {
Vue.set(this.state.control, 'cursor', null)
clearWebSocketState() {
Vue.set(this.state.control, 'clipboard', null)
Vue.set(this.state.control, 'host_id', null)
Vue.set(this.state.control, 'implicit_hosting', false)
@ -591,5 +588,13 @@
Vue.set(this.state, 'session_id', null)
Vue.set(this.state, 'sessions', {})
}
clearWebRTCState() {
Vue.set(this.state.connection.webrtc, 'status', 'disconnected')
Vue.set(this.state.connection.webrtc, 'stats', null)
Vue.set(this.state.connection.webrtc, 'video', null)
Vue.set(this.state.connection.webrtc, 'videos', [])
Vue.set(this.state.connection, 'type', 'none')
}
}
</script>