Fix duplicate register packet (#1214)

This commit is contained in:
sandtechnology 2021-04-25 11:37:12 +08:00 committed by GitHub
parent c3b6342d34
commit 4e070baf34
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -373,7 +373,9 @@ internal class QQAndroidBotNetworkHandler(coroutineContext: CoroutineContext, bo
// StatSvc.Register.offline(bot.client).sendAndExpect()
// }.getOrElse { logger.warning(it) }
return StatSvc.Register.online(bot.client).sendAndExpect()
return StatSvc.Register.online(bot.client).sendAndExpect().also {
lastRegisterResp = it
}
}
private suspend fun updateOtherClientsList() {
@ -398,6 +400,7 @@ internal class QQAndroidBotNetworkHandler(coroutineContext: CoroutineContext, bo
ConcurrentLinkedQueue()
private val contactUpdater: ContactUpdater by lazy { ContactUpdaterImpl(bot) }
private lateinit var lastRegisterResp: StatSvc.Register.Response
override suspend fun init(): Unit = coroutineScope {
check(bot.isActive) { "bot is dead therefore network can't init." }
@ -410,8 +413,6 @@ internal class QQAndroidBotNetworkHandler(coroutineContext: CoroutineContext, bo
_pendingEnabled.value = true
}
val registerResp = registerClientOnline()
this@QQAndroidBotNetworkHandler.launch(
CoroutineName("Awaiting ConfigPushSvc.PushReq"),
block = ConfigPushSyncer()
@ -427,7 +428,7 @@ internal class QQAndroidBotNetworkHandler(coroutineContext: CoroutineContext, bo
}
}
contactUpdater.loadAll(registerResp.origin)
contactUpdater.loadAll(lastRegisterResp.origin)
bot.firstLoginSucceed = true
postInitActions()