1
0
mirror of https://github.com/mamoe/mirai.git synced 2025-03-25 06:50:09 +08:00

add comments

This commit is contained in:
Him188 2019-10-28 21:37:46 +08:00
parent f695c9f792
commit d8e1c87515

View File

@ -32,8 +32,7 @@ import kotlin.coroutines.CoroutineContext
*
* @see BotNetworkHandler
*/
internal class TIMBotNetworkHandler internal constructor(private val bot: Bot) :
BotNetworkHandler<TIMBotNetworkHandler.BotSocketAdapter>, PacketHandlerList() {
internal class TIMBotNetworkHandler internal constructor(private val bot: Bot) : BotNetworkHandler<TIMBotNetworkHandler.BotSocketAdapter>, PacketHandlerList() {
override val coroutineContext: CoroutineContext =
Dispatchers.Default + CoroutineExceptionHandler { _, e -> bot.logger.log(e) } + SupervisorJob()
@ -217,7 +216,7 @@ internal class TIMBotNetworkHandler internal constructor(private val bot: Bot) :
return@coroutineScope
}
// They should be called in sequence otherwise because packet is lock-free
// They should be called in sequence because packet is lock-free
loginHandler.onPacketReceived(packet)
this@TIMBotNetworkHandler.forEach {
it.instance.onPacketReceived(packet)
@ -243,6 +242,24 @@ internal class TIMBotNetworkHandler internal constructor(private val bot: Bot) :
}
}*/
/* todo 修改为这个模式是否更好?
interface Pk
object TestPacket : Pk {
operator fun invoke(bot: UInt):ByteReadPacket = buildPacket {
}
}
override inline fun send(p: ByteReadPacket): UShort {
sendPacket{
// write packet head
// write version
// write bot qq number
writePacket(p)
}
}*/
override suspend fun sendPacket(packet: OutgoingPacket): Unit = withContext(coroutineContext) {
check(channel.isOpen) { "channel is not open" }