Răsfoiți Sursa

Rename `readPacket` to `readPacketExact`

Him188 6 ani în urmă
părinte
comite
a7755cd736

+ 2 - 2
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/QQAndroidBotNetworkHandler.kt

@@ -41,7 +41,7 @@ import net.mamoe.mirai.qqandroid.network.protocol.packet.login.WtLogin
 import net.mamoe.mirai.utils.*
 import net.mamoe.mirai.utils.io.ByteArrayPool
 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 kotlin.coroutines.CoroutineContext
 import kotlin.jvm.Volatile
@@ -445,7 +445,7 @@ internal class QQAndroidBotNetworkHandler(bot: QQAndroidBot) : BotNetworkHandler
             }
             // 循环所有完整的包
             while (rawInput.remaining >= length) {
-                parsePacketAsync(rawInput.readPacket(length))
+                parsePacketAsync(rawInput.readPacketExact(length))
 
                 if (rawInput.remaining == 0L) {
                     cachedPacket.value = null // 表示包长度正好

+ 1 - 1
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network/protocol/packet/PacketFactory.kt

@@ -279,7 +279,7 @@ internal object KnownPacketFactories {
         val commandName: String
         val ssoSequenceId: Int
         val dataCompressed: Int
-        input.readPacket(input.readInt() - 4).withUse {
+        input.readPacketExact(input.readInt() - 4).withUse {
             ssoSequenceId = readInt()
             PacketLogger.verbose { "sequenceId = $ssoSequenceId" }
             val returnCode = readInt()

+ 1 - 1
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/io/input.kt

@@ -56,7 +56,7 @@ inline fun <R> ByteReadPacket.useBytes(
     block(it, n)
 }
 
-inline fun ByteReadPacket.readPacket(
+inline fun ByteReadPacket.readPacketExact(
     n: Int = remaining.toInt()//not that safe but adequate
 ): ByteReadPacket = this.readBytes(n).toReadPacket()