From 8960bb319fbac37f57b95e67f7f7732dee9ad3c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20=C5=A0ediv=C3=BD?= Date: Fri, 18 Jun 2021 23:34:39 +0200 Subject: [PATCH] join clear function. --- src/component/main.vue | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/src/component/main.vue b/src/component/main.vue index a5a954cb..de947f4d 100644 --- a/src/component/main.vue +++ b/src/component/main.vue @@ -274,17 +274,16 @@ this.connection.websocket.send(EVENT.SIGNAL_REQUEST, { video: video }) } - // TODO: Refactor. public disconnect() { if (!this.connected) { throw new Error('client is not connected') } + // TODO: Refactor. this.connection.webrtc.disconnect() - this.clearWebRTCState() this.connection.disconnect() - this.clearWebSocketState() + this.clear() } public play() { @@ -509,19 +508,7 @@ } } - clearWebSocketState() { - Vue.set(this.state.connection, 'websocket', 'disconnected') - Vue.set(this.state.connection.webrtc, 'videos', []) - Vue.set(this.state.control, 'clipboard', null) - Vue.set(this.state.control, 'host_id', null) - Vue.set(this.state.control, 'implicit_hosting', false) - Vue.set(this.state.screen, 'size', { width: 1280, height: 720, rate: 30 }) - Vue.set(this.state.screen, 'configurations', []) - Vue.set(this.state, 'session_id', null) - Vue.set(this.state, 'sessions', {}) - } - - clearWebRTCState() { + clear() { // destroy video if (this._video) { if ('srcObject' in this._video) { @@ -532,6 +519,18 @@ } } + // websocket + Vue.set(this.state.connection, 'websocket', 'disconnected') + Vue.set(this.state.connection.webrtc, 'videos', []) + Vue.set(this.state.control, 'clipboard', null) + Vue.set(this.state.control, 'host_id', null) + Vue.set(this.state.control, 'implicit_hosting', false) + Vue.set(this.state.screen, 'size', { width: 1280, height: 720, rate: 30 }) + Vue.set(this.state.screen, 'configurations', []) + Vue.set(this.state, 'session_id', null) + Vue.set(this.state, 'sessions', {}) + + // webrtc Vue.set(this.state.connection.webrtc, 'status', 'disconnected') Vue.set(this.state.connection.webrtc, 'stats', null) Vue.set(this.state.connection.webrtc, 'video', null)