Commit 26e9f893 authored by Him188's avatar Him188

Atomic packet parser

parent 63a4d5f3
...@@ -176,8 +176,9 @@ internal class QQAndroidBotNetworkHandler(bot: QQAndroidBot) : BotNetworkHandler ...@@ -176,8 +176,9 @@ internal class QQAndroidBotNetworkHandler(bot: QQAndroidBot) : BotNetworkHandler
* *
* @param input 一个完整的包的内容, 去掉开头的 int 包长度 * @param input 一个完整的包的内容, 去掉开头的 int 包长度
*/ */
@UseExperimental(ExperimentalCoroutinesApi::class)
fun parsePacketAsync(input: Input): Job { fun parsePacketAsync(input: Input): Job {
return this.launch { return this.launch(start = CoroutineStart.ATOMIC) {
input.use { parsePacket(it) } input.use { parsePacket(it) }
} }
} }
...@@ -340,10 +341,8 @@ internal class QQAndroidBotNetworkHandler(bot: QQAndroidBot) : BotNetworkHandler ...@@ -340,10 +341,8 @@ internal class QQAndroidBotNetworkHandler(bot: QQAndroidBot) : BotNetworkHandler
bot.tryReinitializeNetworkHandler(e) bot.tryReinitializeNetworkHandler(e)
return return
} }
launch(CoroutineName("Incoming Packet handler"), start = CoroutineStart.ATOMIC) { packetReceiveLock.withLock {
packetReceiveLock.withLock { processPacket(rawInput)
processPacket(rawInput)
}
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment