mirror of
https://github.com/mamoe/mirai.git
synced 2025-03-25 06:50:09 +08:00
Rename readPacket
to readPacketExact
This commit is contained in:
parent
fca3d6bd7a
commit
a7755cd736
mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/network
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/io
@ -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 // 表示包长度正好
|
||||
|
@ -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()
|
||||
|
@ -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()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user