mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
reconnection add debug logs.
This commit is contained in:
parent
3d1b92ae1c
commit
c49c9ad4de
@ -156,9 +156,12 @@ export class NekoConnection extends EventEmitter<NekoConnectionEvents> {
|
|||||||
_websocketIsReconnecting = false
|
_websocketIsReconnecting = false
|
||||||
_websocketReconnect() {
|
_websocketReconnect() {
|
||||||
if (this._websocketIsReconnecting) {
|
if (this._websocketIsReconnecting) {
|
||||||
|
this._log.debug(`websocket reconnection already in progress`)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this._log.debug(`starting websocket reconnection`)
|
||||||
|
|
||||||
setTimeout(async () => {
|
setTimeout(async () => {
|
||||||
while (this._shouldReconnect) {
|
while (this._shouldReconnect) {
|
||||||
try {
|
try {
|
||||||
@ -166,11 +169,12 @@ export class NekoConnection extends EventEmitter<NekoConnectionEvents> {
|
|||||||
this._webrtcReconnect()
|
this._webrtcReconnect()
|
||||||
break
|
break
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this._log.debug(`websocket reconnection`, e)
|
this._log.debug(`websocket reconnection failed`, e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this._websocketIsReconnecting = false
|
this._websocketIsReconnecting = false
|
||||||
|
this._log.debug(`websocket reconnection finished`)
|
||||||
}, 0)
|
}, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -185,21 +189,26 @@ export class NekoConnection extends EventEmitter<NekoConnectionEvents> {
|
|||||||
_webrtcReconnTimer?: number
|
_webrtcReconnTimer?: number
|
||||||
_webrtcReconnect() {
|
_webrtcReconnect() {
|
||||||
if (this._webrtcReconnTimer) {
|
if (this._webrtcReconnTimer) {
|
||||||
|
this._log.debug(`webrtc reconnection already in progress`)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const lastVideo = this._state.webrtc.video ?? undefined
|
const lastVideo = this._state.webrtc.video ?? undefined
|
||||||
|
this._log.debug(`starting webrtc reconnection`)
|
||||||
|
|
||||||
const reconnFunc = async () => {
|
const reconnFunc = async () => {
|
||||||
if (!this._shouldReconnect || !this.websocket.connected || this.webrtc.connected) {
|
if (!this._shouldReconnect || !this.websocket.connected || this.webrtc.connected) {
|
||||||
clearInterval(this._webrtcReconnTimer)
|
clearInterval(this._webrtcReconnTimer)
|
||||||
this._webrtcReconnTimer = undefined
|
this._webrtcReconnTimer = undefined
|
||||||
|
this._log.debug(`webrtc reconnection finished`)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this._webrtcConnect(lastVideo)
|
this._webrtcConnect(lastVideo)
|
||||||
} catch (e) {}
|
} catch (e) {
|
||||||
|
this._log.debug(`webrtc reconnection failed`, e)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this._webrtcReconnTimer = window.setInterval(reconnFunc, 1000)
|
this._webrtcReconnTimer = window.setInterval(reconnFunc, 1000)
|
||||||
|
Loading…
Reference in New Issue
Block a user