Android Protocol - Rebuild Image Protocol

This commit is contained in:
jiahua.liu 2020-01-23 21:06:41 +08:00
parent 5d9dff59ac
commit 4c08503952
2 changed files with 26 additions and 1 deletions

View File

@ -1,9 +1,13 @@
package net.mamoe.mirai.qqandroid.network.protocol.packet.chat.image
import kotlinx.io.core.ByteReadPacket
import kotlinx.serialization.protobuf.ProtoBuf
import net.mamoe.mirai.data.Packet
import net.mamoe.mirai.qqandroid.QQAndroidBot
import net.mamoe.mirai.qqandroid.network.QQAndroidClient
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.buildOutgingPacket
internal object ImageDownPacket : PacketFactory<ImageDownPacket.ImageDownPacketResponse>() {
@ -12,6 +16,15 @@ internal object ImageDownPacket : PacketFactory<ImageDownPacket.ImageDownPacketR
}
operator fun invoke(client: QQAndroidClient, req: GetImgUrlReq): OutgoingPacket {
return buildOutgingPacket(client, this._commandName, this._commandName, client.wLoginSigInfo.d2Key) {
ProtoBuf.dump(
Cmd0x325Packet.serializer(),
Cmd0x325Packet.createByImageRequest(req)
)
}
}
override suspend fun ByteReadPacket.decode(bot: QQAndroidBot): ImageDownPacketResponse {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}

View File

@ -1,9 +1,13 @@
package net.mamoe.mirai.qqandroid.network.protocol.packet.chat.image
import kotlinx.io.core.ByteReadPacket
import kotlinx.serialization.protobuf.ProtoBuf
import net.mamoe.mirai.data.Packet
import net.mamoe.mirai.qqandroid.QQAndroidBot
import net.mamoe.mirai.qqandroid.network.QQAndroidClient
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.buildOutgingPacket
internal object ImageUpPacket : PacketFactory<ImageUpPacket.ImageUpPacketResponse>() {
@ -12,6 +16,15 @@ internal object ImageUpPacket : PacketFactory<ImageUpPacket.ImageUpPacketRespons
}
operator fun invoke(client: QQAndroidClient, req: UploadImgReq): OutgoingPacket {
return buildOutgingPacket(client, this._commandName, this._commandName, client.wLoginSigInfo.d2Key) {
ProtoBuf.dump(
Cmd0x325Packet.serializer(),
Cmd0x325Packet.createByImageRequest(req)
)
}
}
override suspend fun ByteReadPacket.decode(bot: QQAndroidBot): ImageUpPacketResponse {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
@ -21,5 +34,4 @@ internal object ImageUpPacket : PacketFactory<ImageUpPacket.ImageUpPacketRespons
object Success : ImageUpPacketResponse()
}
}