mirror of
https://github.com/m1k1o/neko.git
synced 2025-06-13 08:12:57 +02:00
autoplay video on reconnection.
This commit is contained in:
parent
a4a24a913b
commit
15cfe4c146
2 changed files with 13 additions and 13 deletions
|
@ -15,11 +15,11 @@ export interface NekoConnectionEvents {
|
|||
}
|
||||
|
||||
export class NekoConnection extends EventEmitter<NekoConnectionEvents> {
|
||||
private _shouldReconnect = false
|
||||
private _url: string
|
||||
private _token: string
|
||||
private _activated = false
|
||||
private _url = ''
|
||||
private _token = ''
|
||||
private _log = new Logger('connection')
|
||||
private _state: Connection
|
||||
private _log: Logger
|
||||
|
||||
public websocket = new NekoWebSocket()
|
||||
public webrtc = new NekoWebRTC()
|
||||
|
@ -27,9 +27,6 @@ export class NekoConnection extends EventEmitter<NekoConnectionEvents> {
|
|||
constructor(state: Connection) {
|
||||
super()
|
||||
|
||||
this._url = ''
|
||||
this._token = ''
|
||||
this._log = new Logger('connection')
|
||||
this._state = state
|
||||
|
||||
// initial state
|
||||
|
@ -125,7 +122,7 @@ export class NekoConnection extends EventEmitter<NekoConnectionEvents> {
|
|||
|
||||
await this._webrtcConnect(video)
|
||||
|
||||
this._shouldReconnect = true
|
||||
this._activated = true
|
||||
} catch (e) {
|
||||
this.disconnect()
|
||||
throw e
|
||||
|
@ -133,7 +130,7 @@ export class NekoConnection extends EventEmitter<NekoConnectionEvents> {
|
|||
}
|
||||
|
||||
public disconnect() {
|
||||
this._shouldReconnect = false
|
||||
this._activated = false
|
||||
|
||||
this.webrtc.disconnect()
|
||||
this.websocket.disconnect()
|
||||
|
@ -142,6 +139,10 @@ export class NekoConnection extends EventEmitter<NekoConnectionEvents> {
|
|||
this.emit('disconnect')
|
||||
}
|
||||
|
||||
public get activated() {
|
||||
return this._activated
|
||||
}
|
||||
|
||||
async _websocketConnect() {
|
||||
Vue.set(this._state, 'status', 'connecting')
|
||||
|
||||
|
@ -178,7 +179,7 @@ export class NekoConnection extends EventEmitter<NekoConnectionEvents> {
|
|||
this._log.debug(`starting websocket reconnection`)
|
||||
|
||||
setTimeout(async () => {
|
||||
while (this._shouldReconnect) {
|
||||
while (this.activated) {
|
||||
try {
|
||||
await this._websocketConnect()
|
||||
this._webrtcReconnect()
|
||||
|
@ -228,7 +229,7 @@ export class NekoConnection extends EventEmitter<NekoConnectionEvents> {
|
|||
this._log.debug(`starting webrtc reconnection`)
|
||||
|
||||
setTimeout(async () => {
|
||||
while (this._shouldReconnect && this.websocket.connected) {
|
||||
while (this.activated && this.websocket.connected) {
|
||||
try {
|
||||
await this._webrtcConnect(lastVideo)
|
||||
break
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue