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