mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
periodically reconnect WebRTC.
This commit is contained in:
parent
f9ca3a25db
commit
5f9c565df6
@ -463,7 +463,7 @@
|
|||||||
this.events.emit('connection.webrtc', 'connected')
|
this.events.emit('connection.webrtc', 'connected')
|
||||||
})
|
})
|
||||||
|
|
||||||
let webrtcReconnect: any
|
let webrtcReconnect: any = null
|
||||||
this.webrtc.on('disconnected', () => {
|
this.webrtc.on('disconnected', () => {
|
||||||
this.events.emit('connection.webrtc', 'disconnected')
|
this.events.emit('connection.webrtc', 'disconnected')
|
||||||
this.clearWebRTCState()
|
this.clearWebRTCState()
|
||||||
@ -478,14 +478,21 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// reconnect WebRTC
|
// periodically reconnect WebRTC
|
||||||
if (this.connected) {
|
if (this.connected && !webrtcReconnect) {
|
||||||
if (webrtcReconnect) clearTimeout(webrtcReconnect)
|
webrtcReconnect = setInterval(() => {
|
||||||
|
// connect only if disconnected
|
||||||
webrtcReconnect = setTimeout(() => {
|
if (this.state.connection.webrtc.status == 'disconnected') {
|
||||||
try {
|
try {
|
||||||
this.webrtcConnect()
|
this.webrtcConnect()
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
// stop reconnecting if connected to webrtc or disconnected from WS
|
||||||
|
if (this.state.connection.webrtc.status == 'connected' || !this.connected) {
|
||||||
|
clearInterval(webrtcReconnect)
|
||||||
|
webrtcReconnect = null
|
||||||
|
}
|
||||||
}, 1000)
|
}, 1000)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user