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

Replace object IgnoredPacket with inline class IgnoredPacket to identify each packet

This commit is contained in:
Him188 2019-11-24 16:29:34 +08:00
parent bab2fce71b
commit 825da14f15
3 changed files with 10 additions and 2 deletions
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/network/protocol/tim/packet

View File

@ -9,7 +9,10 @@ import net.mamoe.mirai.utils.io.toUHexString
*/
interface Packet
object IgnoredPacket : Packet
/**
* 被忽略的数据包.
*/
inline class IgnoredPacket(val id: PacketId) : Packet
/**
* 未知的包.

View File

@ -90,5 +90,5 @@ object IgnoredPacketFactory : SessionPacketFactory<IgnoredPacket>() {
override suspend fun BotNetworkHandler<*>.handlePacket(packet: IgnoredPacket) {
}
override suspend fun ByteReadPacket.decode(id: PacketId, sequenceId: UShort, handler: BotNetworkHandler<*>): IgnoredPacket = IgnoredPacket
override suspend fun ByteReadPacket.decode(id: PacketId, sequenceId: UShort, handler: BotNetworkHandler<*>): IgnoredPacket = IgnoredPacket(id)
}

View File

@ -3,4 +3,9 @@ package net.mamoe.mirai.network.protocol.tim.packet.event
import net.mamoe.mirai.event.Subscribable
import net.mamoe.mirai.network.protocol.tim.packet.Packet
/**
* 事件包. 可被监听.
*
* @see Subscribable
*/
interface EventPacket : Subscribable, Packet