mirror of
https://github.com/mamoe/mirai.git
synced 2025-02-03 18:33:49 +08:00
Switch server when neither new bdh session nor cached one found, fix #1001
This commit is contained in:
parent
cda6aaa79b
commit
915e096cc2
@ -293,9 +293,9 @@ internal class QQAndroidBotNetworkHandler(coroutineContext: CoroutineContext, bo
|
|||||||
// return null
|
// return null
|
||||||
// }
|
// }
|
||||||
// }.buildOutgoingUniPacket(bot.client) {}.sendWithoutExpect()
|
// }.buildOutgoingUniPacket(bot.client) {}.sendWithoutExpect()
|
||||||
// kotlin.runCatching {
|
// kotlin.runCatching {
|
||||||
// StatSvc.Register.offline(bot.client).sendAndExpect()
|
// StatSvc.Register.offline(bot.client).sendAndExpect()
|
||||||
// }.getOrElse { logger.warning(it) }
|
// }.getOrElse { logger.warning(it) }
|
||||||
|
|
||||||
return StatSvc.Register.online(bot.client).sendAndExpect()
|
return StatSvc.Register.online(bot.client).sendAndExpect()
|
||||||
}
|
}
|
||||||
@ -336,7 +336,10 @@ internal class QQAndroidBotNetworkHandler(coroutineContext: CoroutineContext, bo
|
|||||||
|
|
||||||
val registerResp = registerClientOnline()
|
val registerResp = registerClientOnline()
|
||||||
|
|
||||||
this@QQAndroidBotNetworkHandler.launch(CoroutineName("Awaiting ConfigPushSvc.PushReq"), block= ConfigPushSyncer())
|
this@QQAndroidBotNetworkHandler.launch(
|
||||||
|
CoroutineName("Awaiting ConfigPushSvc.PushReq"),
|
||||||
|
block = ConfigPushSyncer()
|
||||||
|
)
|
||||||
|
|
||||||
launch {
|
launch {
|
||||||
syncMessageSvc()
|
syncMessageSvc()
|
||||||
@ -354,7 +357,7 @@ internal class QQAndroidBotNetworkHandler(coroutineContext: CoroutineContext, bo
|
|||||||
postInitActions()
|
postInitActions()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Suppress("FunctionName")
|
@Suppress("FunctionName", "UNUSED_VARIABLE")
|
||||||
private fun BotNetworkHandler.ConfigPushSyncer(): suspend CoroutineScope.() -> Unit = launch@{
|
private fun BotNetworkHandler.ConfigPushSyncer(): suspend CoroutineScope.() -> Unit = launch@{
|
||||||
logger.info { "Awaiting ConfigPushSvc.PushReq." }
|
logger.info { "Awaiting ConfigPushSvc.PushReq." }
|
||||||
when (val resp: ConfigPushSvc.PushReq.PushReqResponse? = nextEventOrNull(20_000)) {
|
when (val resp: ConfigPushSvc.PushReq.PushReqResponse? = nextEventOrNull(20_000)) {
|
||||||
@ -362,7 +365,8 @@ internal class QQAndroidBotNetworkHandler(coroutineContext: CoroutineContext, bo
|
|||||||
val hasSession = bot.bdhSyncer.hasSession
|
val hasSession = bot.bdhSyncer.hasSession
|
||||||
kotlin.runCatching { bot.bdhSyncer.bdhSession.completeExceptionally(CancellationException("Timeout waiting for ConfigPushSvc.PushReq")) }
|
kotlin.runCatching { bot.bdhSyncer.bdhSession.completeExceptionally(CancellationException("Timeout waiting for ConfigPushSvc.PushReq")) }
|
||||||
if (!hasSession) {
|
if (!hasSession) {
|
||||||
logger.warning { "Missing ConfigPushSvc.PushReq. File uploading may be affected." }
|
logger.warning { "Missing ConfigPushSvc.PushReq. Switching server..." }
|
||||||
|
bot.launch { BotOfflineEvent.RequireReconnect(bot).broadcast() }
|
||||||
} else {
|
} else {
|
||||||
logger.warning { "Missing ConfigPushSvc.PushReq. Using latest response. File uploading may be affected." }
|
logger.warning { "Missing ConfigPushSvc.PushReq. Using latest response. File uploading may be affected." }
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user