添加重连次数太多的保险措施

This commit is contained in:
John Smith 2023-09-09 23:54:49 +08:00
parent 78828963ce
commit a50461d4e6
3 changed files with 19 additions and 1 deletions

@ -1 +1 @@
Subproject commit 356837c136589b92fb2d9f2f26ad3ae1a338f39d
Subproject commit b1d066b59fabe106ce70a822e9f6e6ba29242519

View File

@ -122,6 +122,15 @@ export default class ChatClientDirectOpenLive extends ChatClientOfficialBase {
return true
}
async onBeforeWsConnect() {
// 重连次数太多则重新init_room保险
let reinitPeriod = Math.max(3, (this.hostServerUrlList || []).length)
if (this.retryCount > 0 && this.retryCount % reinitPeriod === 0) {
this.needInitRoom = true
}
return super.onBeforeWsConnect()
}
getWsUrl() {
return this.hostServerUrlList[this.retryCount % this.hostServerUrlList.length]
}

View File

@ -35,6 +35,15 @@ export default class ChatClientDirectWeb extends ChatClientOfficialBase {
return true
}
async onBeforeWsConnect() {
// 重连次数太多则重新init_room保险
let reinitPeriod = Math.max(3, (this.hostServerList || []).length)
if (this.retryCount > 0 && this.retryCount % reinitPeriod === 0) {
this.needInitRoom = true
}
return super.onBeforeWsConnect()
}
getWsUrl() {
let hostServer = this.hostServerList[this.retryCount % this.hostServerList.length]
return `wss://${hostServer.host}:${hostServer.wss_port}/sub`