mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
remove async connection.
This commit is contained in:
parent
b3a8d5f86d
commit
0408acd211
@ -33,7 +33,7 @@ class WebsocketReconnecter extends ReconnecterAbstract {
|
|||||||
return this._websocket.connected
|
return this._websocket.connected
|
||||||
}
|
}
|
||||||
|
|
||||||
public async connect() {
|
public connect() {
|
||||||
let url = this._state.url
|
let url = this._state.url
|
||||||
url = url.replace(/^http/, 'ws').replace(/\/+$/, '') + '/api/ws'
|
url = url.replace(/^http/, 'ws').replace(/\/+$/, '') + '/api/ws'
|
||||||
|
|
||||||
@ -45,7 +45,7 @@ class WebsocketReconnecter extends ReconnecterAbstract {
|
|||||||
this._websocket.connect(url)
|
this._websocket.connect(url)
|
||||||
}
|
}
|
||||||
|
|
||||||
public async disconnect() {
|
public disconnect() {
|
||||||
this._websocket.disconnect()
|
this._websocket.disconnect()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -71,13 +71,13 @@ class WebrtcReconnecter extends ReconnecterAbstract {
|
|||||||
return this._webrtc.connected
|
return this._webrtc.connected
|
||||||
}
|
}
|
||||||
|
|
||||||
public async connect() {
|
public connect() {
|
||||||
if (this._websocket.connected) {
|
if (this._websocket.connected) {
|
||||||
this._websocket.send(EVENT.SIGNAL_REQUEST, { video: this._state.webrtc.video })
|
this._websocket.send(EVENT.SIGNAL_REQUEST, { video: this._state.webrtc.video })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async disconnect() {
|
public disconnect() {
|
||||||
this._webrtc.disconnect()
|
this._webrtc.disconnect()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -110,12 +110,12 @@ export class NekoConnection extends EventEmitter<NekoConnectionEvents> {
|
|||||||
Vue.set(this._state, 'status', 'connected')
|
Vue.set(this._state, 'status', 'connected')
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this._webrtc_reconn.isConnected) {
|
if (!this.webrtc.connected) {
|
||||||
this._webrtc_reconn.connect()
|
this._webrtc_reconn.connect()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
this._websocket_reconn.on('disconnect', () => {
|
this._websocket_reconn.on('disconnect', () => {
|
||||||
if (this._state.status === 'connected') {
|
if (this._state.status === 'connected' && this.activated) {
|
||||||
Vue.set(this._state, 'status', 'connecting')
|
Vue.set(this._state, 'status', 'connecting')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -132,7 +132,7 @@ export class NekoConnection extends EventEmitter<NekoConnectionEvents> {
|
|||||||
Vue.set(this._state, 'type', 'webrtc')
|
Vue.set(this._state, 'type', 'webrtc')
|
||||||
})
|
})
|
||||||
this._webrtc_reconn.on('disconnect', () => {
|
this._webrtc_reconn.on('disconnect', () => {
|
||||||
if (this._state.status === 'connected') {
|
if (this._state.status === 'connected' && this.activated) {
|
||||||
Vue.set(this._state, 'status', 'connecting')
|
Vue.set(this._state, 'status', 'connecting')
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -196,7 +196,7 @@ export class NekoConnection extends EventEmitter<NekoConnectionEvents> {
|
|||||||
this.websocket.send(EVENT.SIGNAL_VIDEO, { video })
|
this.websocket.send(EVENT.SIGNAL_VIDEO, { video })
|
||||||
}
|
}
|
||||||
|
|
||||||
public async connect(video?: string): Promise<void> {
|
public connect(video?: string) {
|
||||||
if (video) {
|
if (video) {
|
||||||
if (!this._state.webrtc.videos.includes(video)) {
|
if (!this._state.webrtc.videos.includes(video)) {
|
||||||
throw new Error('video id not found')
|
throw new Error('video id not found')
|
||||||
|
@ -212,7 +212,7 @@
|
|||||||
await this.authenticate()
|
await this.authenticate()
|
||||||
|
|
||||||
if (!this.autoconnect) return
|
if (!this.autoconnect) return
|
||||||
await this.connect()
|
this.connect()
|
||||||
}
|
}
|
||||||
|
|
||||||
public async authenticate(token?: string) {
|
public async authenticate(token?: string) {
|
||||||
@ -274,7 +274,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async connect(video?: string) {
|
public connect(video?: string) {
|
||||||
if (!this.state.authenticated) {
|
if (!this.state.authenticated) {
|
||||||
throw new Error('client not authenticated')
|
throw new Error('client not authenticated')
|
||||||
}
|
}
|
||||||
@ -283,7 +283,7 @@
|
|||||||
throw new Error('client is already connected')
|
throw new Error('client is already connected')
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.connection.connect(video)
|
this.connection.connect(video)
|
||||||
}
|
}
|
||||||
|
|
||||||
public disconnect() {
|
public disconnect() {
|
||||||
|
@ -19,11 +19,11 @@ export abstract class ReconnecterAbstract extends EventEmitter<ReconnecterAbstra
|
|||||||
throw new Error("Getter'connected()' must be implemented.")
|
throw new Error("Getter'connected()' must be implemented.")
|
||||||
}
|
}
|
||||||
|
|
||||||
public async connect() {
|
public connect() {
|
||||||
throw new Error("Method 'connect()' must be implemented.")
|
throw new Error("Method 'connect()' must be implemented.")
|
||||||
}
|
}
|
||||||
|
|
||||||
public async disconnect() {
|
public disconnect() {
|
||||||
throw new Error("Method 'disconnect()' must be implemented.")
|
throw new Error("Method 'disconnect()' must be implemented.")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user