mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-10 02:20:14 +08:00
Add asJceInput
This commit is contained in:
parent
c12e3ae15a
commit
baee2d6366
@ -3,6 +3,7 @@ package net.mamoe.mirai.qqandroid.network.io
|
|||||||
import kotlinx.io.charsets.Charset
|
import kotlinx.io.charsets.Charset
|
||||||
import kotlinx.io.core.*
|
import kotlinx.io.core.*
|
||||||
import kotlinx.io.pool.ObjectPool
|
import kotlinx.io.pool.ObjectPool
|
||||||
|
import net.mamoe.mirai.utils.io.readIoBuffer
|
||||||
import net.mamoe.mirai.utils.io.readString
|
import net.mamoe.mirai.utils.io.readString
|
||||||
import net.mamoe.mirai.utils.io.toIoBuffer
|
import net.mamoe.mirai.utils.io.toIoBuffer
|
||||||
|
|
||||||
@ -20,6 +21,8 @@ inline class JceHead(private val value: Long) {
|
|||||||
|
|
||||||
fun ByteArray.asJceInput(charset: Charset = CharsetGBK): JceInput = JceInput(this.toIoBuffer(), charset)
|
fun ByteArray.asJceInput(charset: Charset = CharsetGBK): JceInput = JceInput(this.toIoBuffer(), charset)
|
||||||
|
|
||||||
|
fun ByteReadPacket.asJceInput(charset: Charset = CharsetGBK): JceInput = JceInput(this.readIoBuffer(), charset)
|
||||||
|
|
||||||
@Suppress("MemberVisibilityCanBePrivate")
|
@Suppress("MemberVisibilityCanBePrivate")
|
||||||
@UseExperimental(ExperimentalUnsignedTypes::class)
|
@UseExperimental(ExperimentalUnsignedTypes::class)
|
||||||
class JceInput(
|
class JceInput(
|
||||||
|
@ -7,6 +7,8 @@ import kotlin.reflect.KClass
|
|||||||
|
|
||||||
@PublishedApi
|
@PublishedApi
|
||||||
internal val CharsetGBK = Charset.forName("GBK")
|
internal val CharsetGBK = Charset.forName("GBK")
|
||||||
|
@PublishedApi
|
||||||
|
internal val CharsetUTF8 = Charset.forName("UTF8")
|
||||||
|
|
||||||
inline fun buildJcePacket(stringCharset: Charset = CharsetGBK, block: JceOutput.() -> Unit): ByteReadPacket {
|
inline fun buildJcePacket(stringCharset: Charset = CharsetGBK, block: JceOutput.() -> Unit): ByteReadPacket {
|
||||||
return JceOutput(stringCharset).apply(block).build()
|
return JceOutput(stringCharset).apply(block).build()
|
||||||
|
Loading…
Reference in New Issue
Block a user