mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
do not destroy WebRTC on WS disconnect.
This commit is contained in:
parent
5178c4c36f
commit
80d229041a
@ -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>
|
||||||
|
Loading…
Reference in New Issue
Block a user