From 154c91e73bd4d731c58035b7dfcd202fbff5d73a Mon Sep 17 00:00:00 2001 From: "jiahua.liu" Date: Mon, 27 Jan 2020 17:42:04 +0800 Subject: [PATCH 1/3] PushNotify --- .../packet/chat/receive/MessageSvc.PushNotify.kt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/chat/receive/MessageSvc.PushNotify.kt b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/chat/receive/MessageSvc.PushNotify.kt index 12ae416b5..d429fc72b 100644 --- a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/chat/receive/MessageSvc.PushNotify.kt +++ b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/chat/receive/MessageSvc.PushNotify.kt @@ -6,17 +6,24 @@ import net.mamoe.mirai.qqandroid.QQAndroidBot import net.mamoe.mirai.qqandroid.network.io.JceInput import net.mamoe.mirai.qqandroid.network.io.JceOutput import net.mamoe.mirai.qqandroid.network.io.JceStruct +import net.mamoe.mirai.qqandroid.network.protocol.jce.RequestPacket import net.mamoe.mirai.qqandroid.network.protocol.packet.EMPTY_BYTE_ARRAY import net.mamoe.mirai.qqandroid.network.protocol.packet.PacketFactory import net.mamoe.mirai.utils.io.discardExact import net.mamoe.mirai.utils.io.readIoBuffer +import net.mamoe.mirai.utils.io.toReadPacket import net.mamoe.mirai.utils.io.toUHexString internal object PushNotify : PacketFactory("MessageSvc.PushNotify") { override suspend fun ByteReadPacket.decode(bot: QQAndroidBot): MessageNotification { - return MessageNotification.newInstanceFrom(JceInput(this.apply { discardExact(4) }.readIoBuffer())) + val pk = RequestPacket.newInstanceFrom(JceInput(this.apply { discardExact(4) }.readIoBuffer())) + println(pk.sFuncName) + println(pk.sServantName) + println(pk.sBuffer.toUHexString()) + return MessageNotification.newInstanceFrom(JceInput(pk.sBuffer.toReadPacket(4))) } + class MessageNotification( val luni: Long, val ctype: Byte, From 016cc16b557861eb9feb4e5f568420b058858c23 Mon Sep 17 00:00:00 2001 From: "jiahua.liu" Date: Mon, 27 Jan 2020 18:14:31 +0800 Subject: [PATCH 2/3] PushNotify --- .../packet/chat/receive/MessageSvc.PushNotify.kt | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/chat/receive/MessageSvc.PushNotify.kt b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/chat/receive/MessageSvc.PushNotify.kt index d429fc72b..230b19714 100644 --- a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/chat/receive/MessageSvc.PushNotify.kt +++ b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/chat/receive/MessageSvc.PushNotify.kt @@ -3,24 +3,17 @@ package net.mamoe.mirai.qqandroid.network.protocol.packet.chat.receive import kotlinx.io.core.ByteReadPacket import net.mamoe.mirai.data.Packet import net.mamoe.mirai.qqandroid.QQAndroidBot -import net.mamoe.mirai.qqandroid.network.io.JceInput -import net.mamoe.mirai.qqandroid.network.io.JceOutput -import net.mamoe.mirai.qqandroid.network.io.JceStruct +import net.mamoe.mirai.qqandroid.network.io.* import net.mamoe.mirai.qqandroid.network.protocol.jce.RequestPacket import net.mamoe.mirai.qqandroid.network.protocol.packet.EMPTY_BYTE_ARRAY import net.mamoe.mirai.qqandroid.network.protocol.packet.PacketFactory import net.mamoe.mirai.utils.io.discardExact -import net.mamoe.mirai.utils.io.readIoBuffer -import net.mamoe.mirai.utils.io.toReadPacket import net.mamoe.mirai.utils.io.toUHexString internal object PushNotify : PacketFactory("MessageSvc.PushNotify") { override suspend fun ByteReadPacket.decode(bot: QQAndroidBot): MessageNotification { - val pk = RequestPacket.newInstanceFrom(JceInput(this.apply { discardExact(4) }.readIoBuffer())) - println(pk.sFuncName) - println(pk.sServantName) - println(pk.sBuffer.toUHexString()) - return MessageNotification.newInstanceFrom(JceInput(pk.sBuffer.toReadPacket(4))) + val request = RequestPacket.newInstanceFrom(this.apply { discardExact(4) }.asJceInput(CharsetUTF8)) + return MessageNotification.newInstanceFrom(request.sBuffer.asJceInput(CharsetUTF8)) } From 81b347967f5d273d6c3ba8118ae44186f62210b8 Mon Sep 17 00:00:00 2001 From: "jiahua.liu" Date: Mon, 27 Jan 2020 21:06:51 +0800 Subject: [PATCH 3/3] PushNotify --- .../chat/receive/{MessageSvc.PushNotify.kt => MessageSvc.kt} | 1 - 1 file changed, 1 deletion(-) rename mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/chat/receive/{MessageSvc.PushNotify.kt => MessageSvc.kt} (99%) diff --git a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/chat/receive/MessageSvc.PushNotify.kt b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/chat/receive/MessageSvc.kt similarity index 99% rename from mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/chat/receive/MessageSvc.PushNotify.kt rename to mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/chat/receive/MessageSvc.kt index 59f8cae90..9c1b9e456 100644 --- a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/chat/receive/MessageSvc.PushNotify.kt +++ b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/chat/receive/MessageSvc.kt @@ -14,6 +14,5 @@ class MessageSvc { println(messageNotification.contentToString()) TODO() } - } } \ No newline at end of file