mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-10 02:20:14 +08:00
Move packets
This commit is contained in:
parent
27dbfcfb39
commit
dd7fb68b1c
@ -8,9 +8,9 @@ import kotlinx.serialization.modules.EmptyModule
|
|||||||
import kotlinx.serialization.modules.SerialModule
|
import kotlinx.serialization.modules.SerialModule
|
||||||
import net.mamoe.mirai.qqandroid.io.JceStruct
|
import net.mamoe.mirai.qqandroid.io.JceStruct
|
||||||
import net.mamoe.mirai.qqandroid.io.ProtoBuf
|
import net.mamoe.mirai.qqandroid.io.ProtoBuf
|
||||||
import net.mamoe.mirai.qqandroid.network.protocol.packet.login.data.RequestDataVersion2
|
import net.mamoe.mirai.qqandroid.network.protocol.data.jce.RequestDataVersion2
|
||||||
import net.mamoe.mirai.qqandroid.network.protocol.packet.login.data.RequestDataVersion3
|
import net.mamoe.mirai.qqandroid.network.protocol.data.jce.RequestDataVersion3
|
||||||
import net.mamoe.mirai.qqandroid.network.protocol.packet.login.data.RequestPacket
|
import net.mamoe.mirai.qqandroid.network.protocol.data.jce.RequestPacket
|
||||||
import net.mamoe.mirai.qqandroid.network.protocol.packet.withUse
|
import net.mamoe.mirai.qqandroid.network.protocol.packet.withUse
|
||||||
import net.mamoe.mirai.utils.firstValue
|
import net.mamoe.mirai.utils.firstValue
|
||||||
import net.mamoe.mirai.utils.io.read
|
import net.mamoe.mirai.utils.io.read
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package net.mamoe.mirai.qqandroid.network.protocol.packet.login.data
|
package net.mamoe.mirai.qqandroid.network.protocol.data.jce
|
||||||
|
|
||||||
import kotlinx.serialization.SerialId
|
import kotlinx.serialization.SerialId
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
@ -1,4 +1,4 @@
|
|||||||
package net.mamoe.mirai.qqandroid.network.protocol.packet.login.data
|
package net.mamoe.mirai.qqandroid.network.protocol.data.jce
|
||||||
|
|
||||||
import kotlinx.serialization.Polymorphic
|
import kotlinx.serialization.Polymorphic
|
||||||
import kotlinx.serialization.SerialId
|
import kotlinx.serialization.SerialId
|
@ -6,11 +6,11 @@ import net.mamoe.mirai.data.Packet
|
|||||||
import net.mamoe.mirai.event.Subscribable
|
import net.mamoe.mirai.event.Subscribable
|
||||||
import net.mamoe.mirai.qqandroid.QQAndroidBot
|
import net.mamoe.mirai.qqandroid.QQAndroidBot
|
||||||
import net.mamoe.mirai.qqandroid.io.serialization.loadAs
|
import net.mamoe.mirai.qqandroid.io.serialization.loadAs
|
||||||
|
import net.mamoe.mirai.qqandroid.network.protocol.data.jce.RequestPacket
|
||||||
import net.mamoe.mirai.qqandroid.network.protocol.packet.chat.receive.MessageSvc
|
import net.mamoe.mirai.qqandroid.network.protocol.packet.chat.receive.MessageSvc
|
||||||
import net.mamoe.mirai.qqandroid.network.protocol.packet.chat.receive.OnlinePush
|
import net.mamoe.mirai.qqandroid.network.protocol.packet.chat.receive.OnlinePush
|
||||||
import net.mamoe.mirai.qqandroid.network.protocol.packet.login.LoginPacket
|
import net.mamoe.mirai.qqandroid.network.protocol.packet.login.LoginPacket
|
||||||
import net.mamoe.mirai.qqandroid.network.protocol.packet.login.StatSvc
|
import net.mamoe.mirai.qqandroid.network.protocol.packet.login.StatSvc
|
||||||
import net.mamoe.mirai.qqandroid.network.protocol.packet.login.data.RequestPacket
|
|
||||||
import net.mamoe.mirai.utils.DefaultLogger
|
import net.mamoe.mirai.utils.DefaultLogger
|
||||||
import net.mamoe.mirai.utils.MiraiLogger
|
import net.mamoe.mirai.utils.MiraiLogger
|
||||||
import net.mamoe.mirai.utils.cryptor.adjustToPublicKey
|
import net.mamoe.mirai.utils.cryptor.adjustToPublicKey
|
||||||
@ -79,12 +79,7 @@ internal object KnownPacketFactories : List<PacketFactory<*>> by mutableListOf(
|
|||||||
*/
|
*/
|
||||||
// do not inline. Exceptions thrown will not be reported correctly
|
// do not inline. Exceptions thrown will not be reported correctly
|
||||||
@Suppress("UNCHECKED_CAST")
|
@Suppress("UNCHECKED_CAST")
|
||||||
suspend fun <T : Packet> parseIncomingPacket(bot: QQAndroidBot, rawInput: Input, consumer: PacketConsumer<T>) {
|
suspend fun <T : Packet> parseIncomingPacket(bot: QQAndroidBot, rawInput: Input, consumer: PacketConsumer<T>) = with(rawInput) {
|
||||||
rawInput.readBytes().let {
|
|
||||||
PacketLogger.verbose("开始处理包: ${it.toUHexString()}")
|
|
||||||
it.toReadPacket()
|
|
||||||
}.apply {
|
|
||||||
require(remaining < Int.MAX_VALUE) { "rawInput is too long" }
|
|
||||||
// login
|
// login
|
||||||
val flag1 = readInt()
|
val flag1 = readInt()
|
||||||
|
|
||||||
@ -155,7 +150,6 @@ internal object KnownPacketFactories : List<PacketFactory<*>> by mutableListOf(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private inline fun <R> inline(block: () -> R): R = block()
|
private inline fun <R> inline(block: () -> R): R = block()
|
||||||
|
|
||||||
|
@ -8,8 +8,6 @@ import net.mamoe.mirai.qqandroid.QQAndroidBot
|
|||||||
import net.mamoe.mirai.qqandroid.event.ForceOfflineEvent
|
import net.mamoe.mirai.qqandroid.event.ForceOfflineEvent
|
||||||
import net.mamoe.mirai.qqandroid.io.readRemainingAsProtoBuf
|
import net.mamoe.mirai.qqandroid.io.readRemainingAsProtoBuf
|
||||||
import net.mamoe.mirai.qqandroid.io.serialization.decodeUniPacket
|
import net.mamoe.mirai.qqandroid.io.serialization.decodeUniPacket
|
||||||
import net.mamoe.mirai.qqandroid.io.serialization.loadAs
|
|
||||||
import net.mamoe.mirai.qqandroid.io.serialization.readRemainingAsJceStruct
|
|
||||||
import net.mamoe.mirai.qqandroid.io.writeProtoBuf
|
import net.mamoe.mirai.qqandroid.io.writeProtoBuf
|
||||||
import net.mamoe.mirai.qqandroid.network.QQAndroidClient
|
import net.mamoe.mirai.qqandroid.network.QQAndroidClient
|
||||||
import net.mamoe.mirai.qqandroid.network.protocol.data.jce.RequestPushForceOffline
|
import net.mamoe.mirai.qqandroid.network.protocol.data.jce.RequestPushForceOffline
|
||||||
@ -18,11 +16,8 @@ import net.mamoe.mirai.qqandroid.network.protocol.data.proto.MsgSvc
|
|||||||
import net.mamoe.mirai.qqandroid.network.protocol.packet.OutgoingPacket
|
import net.mamoe.mirai.qqandroid.network.protocol.packet.OutgoingPacket
|
||||||
import net.mamoe.mirai.qqandroid.network.protocol.packet.PacketFactory
|
import net.mamoe.mirai.qqandroid.network.protocol.packet.PacketFactory
|
||||||
import net.mamoe.mirai.qqandroid.network.protocol.packet.buildOutgoingUniPacket
|
import net.mamoe.mirai.qqandroid.network.protocol.packet.buildOutgoingUniPacket
|
||||||
import net.mamoe.mirai.qqandroid.network.protocol.packet.login.data.RequestDataVersion2
|
|
||||||
import net.mamoe.mirai.qqandroid.network.protocol.packet.login.data.RequestPacket
|
|
||||||
import net.mamoe.mirai.qqandroid.utils.toMessageChain
|
import net.mamoe.mirai.qqandroid.utils.toMessageChain
|
||||||
import net.mamoe.mirai.utils.cryptor.contentToString
|
import net.mamoe.mirai.utils.cryptor.contentToString
|
||||||
import net.mamoe.mirai.utils.firstValue
|
|
||||||
import net.mamoe.mirai.utils.io.hexToBytes
|
import net.mamoe.mirai.utils.io.hexToBytes
|
||||||
import net.mamoe.mirai.utils.io.toReadPacket
|
import net.mamoe.mirai.utils.io.toReadPacket
|
||||||
|
|
||||||
|
@ -7,10 +7,10 @@ import net.mamoe.mirai.qqandroid.QQAndroidBot
|
|||||||
import net.mamoe.mirai.qqandroid.io.serialization.toByteArray
|
import net.mamoe.mirai.qqandroid.io.serialization.toByteArray
|
||||||
import net.mamoe.mirai.qqandroid.io.serialization.writeJceStruct
|
import net.mamoe.mirai.qqandroid.io.serialization.writeJceStruct
|
||||||
import net.mamoe.mirai.qqandroid.network.QQAndroidClient
|
import net.mamoe.mirai.qqandroid.network.QQAndroidClient
|
||||||
import net.mamoe.mirai.qqandroid.network.protocol.packet.login.data.RequestDataStructSvcReqRegister
|
import net.mamoe.mirai.qqandroid.network.protocol.data.jce.RequestDataStructSvcReqRegister
|
||||||
import net.mamoe.mirai.qqandroid.network.protocol.packet.login.data.RequestDataVersion3
|
import net.mamoe.mirai.qqandroid.network.protocol.data.jce.RequestDataVersion3
|
||||||
import net.mamoe.mirai.qqandroid.network.protocol.packet.login.data.RequestPacket
|
import net.mamoe.mirai.qqandroid.network.protocol.data.jce.RequestPacket
|
||||||
import net.mamoe.mirai.qqandroid.network.protocol.packet.login.data.SvcReqRegister
|
import net.mamoe.mirai.qqandroid.network.protocol.data.jce.SvcReqRegister
|
||||||
import net.mamoe.mirai.qqandroid.network.protocol.packet.OutgoingPacket
|
import net.mamoe.mirai.qqandroid.network.protocol.packet.OutgoingPacket
|
||||||
import net.mamoe.mirai.qqandroid.network.protocol.packet.PacketFactory
|
import net.mamoe.mirai.qqandroid.network.protocol.packet.PacketFactory
|
||||||
import net.mamoe.mirai.qqandroid.network.protocol.packet.buildLoginOutgoingPacket
|
import net.mamoe.mirai.qqandroid.network.protocol.packet.buildLoginOutgoingPacket
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package net.mamoe.mirai.qqandroid.io.serialization
|
package net.mamoe.mirai.qqandroid.io.serialization
|
||||||
|
|
||||||
import net.mamoe.mirai.qqandroid.network.protocol.packet.login.data.RequestPacket
|
import net.mamoe.mirai.qqandroid.network.protocol.data.jce.RequestPacket
|
||||||
import net.mamoe.mirai.utils.io.hexToBytes
|
import net.mamoe.mirai.utils.io.hexToBytes
|
||||||
|
|
||||||
class TestRequesetPacket {
|
class TestRequesetPacket {
|
||||||
|
Loading…
Reference in New Issue
Block a user