remove async connection.

This commit is contained in:
Miroslav Šedivý 2021-07-17 15:45:41 +02:00
parent b3a8d5f86d
commit 0408acd211
3 changed files with 13 additions and 13 deletions

View File

@ -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<NekoConnectionEvents> {
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<NekoConnectionEvents> {
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<NekoConnectionEvents> {
this.websocket.send(EVENT.SIGNAL_VIDEO, { video })
}
public async connect(video?: string): Promise<void> {
public connect(video?: string) {
if (video) {
if (!this._state.webrtc.videos.includes(video)) {
throw new Error('video id not found')

View File

@ -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() {

View File

@ -19,11 +19,11 @@ export abstract class ReconnecterAbstract extends EventEmitter<ReconnecterAbstra
throw new Error("Getter'connected()' must be implemented.")
}
public async connect() {
public connect() {
throw new Error("Method 'connect()' must be implemented.")
}
public async disconnect() {
public disconnect() {
throw new Error("Method 'disconnect()' must be implemented.")
}
}