mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-18 11:54:59 -04:00
network: fix string writing
This commit is contained in:
parent
d37ef51ca3
commit
0412be8d63
@ -66,8 +66,9 @@ open class OutByteBuffer(open val connection: Connection? = null) {
|
|||||||
|
|
||||||
fun writeString(string: String) {
|
fun writeString(string: String) {
|
||||||
check(string.length <= ProtocolDefinition.STRING_MAX_LENGTH) { "String max string length exceeded ${string.length} > ${ProtocolDefinition.STRING_MAX_LENGTH}" }
|
check(string.length <= ProtocolDefinition.STRING_MAX_LENGTH) { "String max string length exceeded ${string.length} > ${ProtocolDefinition.STRING_MAX_LENGTH}" }
|
||||||
writeVarInt(string.length)
|
val bytes = string.toByteArray(StandardCharsets.UTF_8)
|
||||||
writeUnprefixedByteArray(string.toByteArray(StandardCharsets.UTF_8))
|
writeVarInt(bytes.size)
|
||||||
|
writeUnprefixedByteArray(bytes)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun writeVarLong(long: Long) {
|
fun writeVarLong(long: Long) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user