Commit a7755cd7 authored by Him188's avatar Him188

Rename `readPacket` to `readPacketExact`

parent fca3d6bd
...@@ -41,7 +41,7 @@ import net.mamoe.mirai.qqandroid.network.protocol.packet.login.WtLogin ...@@ -41,7 +41,7 @@ import net.mamoe.mirai.qqandroid.network.protocol.packet.login.WtLogin
import net.mamoe.mirai.utils.* import net.mamoe.mirai.utils.*
import net.mamoe.mirai.utils.io.ByteArrayPool import net.mamoe.mirai.utils.io.ByteArrayPool
import net.mamoe.mirai.utils.io.PlatformSocket import net.mamoe.mirai.utils.io.PlatformSocket
import net.mamoe.mirai.utils.io.readPacket import net.mamoe.mirai.utils.io.readPacketExact
import net.mamoe.mirai.utils.io.useBytes import net.mamoe.mirai.utils.io.useBytes
import kotlin.coroutines.CoroutineContext import kotlin.coroutines.CoroutineContext
import kotlin.jvm.Volatile import kotlin.jvm.Volatile
...@@ -445,7 +445,7 @@ internal class QQAndroidBotNetworkHandler(bot: QQAndroidBot) : BotNetworkHandler ...@@ -445,7 +445,7 @@ internal class QQAndroidBotNetworkHandler(bot: QQAndroidBot) : BotNetworkHandler
} }
// 循环所有完整的包 // 循环所有完整的包
while (rawInput.remaining >= length) { while (rawInput.remaining >= length) {
parsePacketAsync(rawInput.readPacket(length)) parsePacketAsync(rawInput.readPacketExact(length))
if (rawInput.remaining == 0L) { if (rawInput.remaining == 0L) {
cachedPacket.value = null // 表示包长度正好 cachedPacket.value = null // 表示包长度正好
......
...@@ -279,7 +279,7 @@ internal object KnownPacketFactories { ...@@ -279,7 +279,7 @@ internal object KnownPacketFactories {
val commandName: String val commandName: String
val ssoSequenceId: Int val ssoSequenceId: Int
val dataCompressed: Int val dataCompressed: Int
input.readPacket(input.readInt() - 4).withUse { input.readPacketExact(input.readInt() - 4).withUse {
ssoSequenceId = readInt() ssoSequenceId = readInt()
PacketLogger.verbose { "sequenceId = $ssoSequenceId" } PacketLogger.verbose { "sequenceId = $ssoSequenceId" }
val returnCode = readInt() val returnCode = readInt()
......
...@@ -56,7 +56,7 @@ inline fun <R> ByteReadPacket.useBytes( ...@@ -56,7 +56,7 @@ inline fun <R> ByteReadPacket.useBytes(
block(it, n) block(it, n)
} }
inline fun ByteReadPacket.readPacket( inline fun ByteReadPacket.readPacketExact(
n: Int = remaining.toInt()//not that safe but adequate n: Int = remaining.toInt()//not that safe but adequate
): ByteReadPacket = this.readBytes(n).toReadPacket() ): ByteReadPacket = this.readBytes(n).toReadPacket()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment