From 0408acd2113363040e34fb418dccbc21a1e0b948 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20=C5=A0ediv=C3=BD?= Date: Sat, 17 Jul 2021 15:45:41 +0200 Subject: [PATCH] remove async connection. --- src/component/internal/connection.ts | 16 ++++++++-------- src/component/main.vue | 6 +++--- src/component/utils/reconnecter.ts | 4 ++-- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/component/internal/connection.ts b/src/component/internal/connection.ts index fe722498..c58e5176 100644 --- a/src/component/internal/connection.ts +++ b/src/component/internal/connection.ts @@ -33,7 +33,7 @@ class WebsocketReconnecter extends ReconnecterAbstract { return this._websocket.connected } - public async connect() { + public connect() { let url = this._state.url url = url.replace(/^http/, 'ws').replace(/\/+$/, '') + '/api/ws' @@ -45,7 +45,7 @@ class WebsocketReconnecter extends ReconnecterAbstract { this._websocket.connect(url) } - public async disconnect() { + public disconnect() { this._websocket.disconnect() } } @@ -71,13 +71,13 @@ class WebrtcReconnecter extends ReconnecterAbstract { return this._webrtc.connected } - public async connect() { + public connect() { if (this._websocket.connected) { this._websocket.send(EVENT.SIGNAL_REQUEST, { video: this._state.webrtc.video }) } } - public async disconnect() { + public disconnect() { this._webrtc.disconnect() } } @@ -110,12 +110,12 @@ export class NekoConnection extends EventEmitter { Vue.set(this._state, 'status', 'connected') } - if (!this._webrtc_reconn.isConnected) { + if (!this.webrtc.connected) { this._webrtc_reconn.connect() } }) this._websocket_reconn.on('disconnect', () => { - if (this._state.status === 'connected') { + if (this._state.status === 'connected' && this.activated) { Vue.set(this._state, 'status', 'connecting') } }) @@ -132,7 +132,7 @@ export class NekoConnection extends EventEmitter { Vue.set(this._state, 'type', 'webrtc') }) this._webrtc_reconn.on('disconnect', () => { - if (this._state.status === 'connected') { + if (this._state.status === 'connected' && this.activated) { Vue.set(this._state, 'status', 'connecting') } @@ -196,7 +196,7 @@ export class NekoConnection extends EventEmitter { this.websocket.send(EVENT.SIGNAL_VIDEO, { video }) } - public async connect(video?: string): Promise { + public connect(video?: string) { if (video) { if (!this._state.webrtc.videos.includes(video)) { throw new Error('video id not found') diff --git a/src/component/main.vue b/src/component/main.vue index 1147564f..a45a1707 100644 --- a/src/component/main.vue +++ b/src/component/main.vue @@ -212,7 +212,7 @@ await this.authenticate() if (!this.autoconnect) return - await this.connect() + this.connect() } public async authenticate(token?: string) { @@ -274,7 +274,7 @@ } } - public async connect(video?: string) { + public connect(video?: string) { if (!this.state.authenticated) { throw new Error('client not authenticated') } @@ -283,7 +283,7 @@ throw new Error('client is already connected') } - await this.connection.connect(video) + this.connection.connect(video) } public disconnect() { diff --git a/src/component/utils/reconnecter.ts b/src/component/utils/reconnecter.ts index 44b38228..0278b201 100644 --- a/src/component/utils/reconnecter.ts +++ b/src/component/utils/reconnecter.ts @@ -19,11 +19,11 @@ export abstract class ReconnecterAbstract extends EventEmitter