Open-source multiplayer game server compatible with the RuneScape client https://www.openrs2.org/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
openrs2/protocol/src/test/kotlin/org/openrs2/protocol/VariableByteOptimisedPacket...

23 lines
768 B

package org.openrs2.protocol
import io.netty.buffer.ByteBuf
import org.openrs2.crypto.StreamCipher
internal object VariableByteOptimisedPacketCodec : VariableBytePacketCodec<VariableByteOptimisedPacket>(
type = VariableByteOptimisedPacket::class.java,
opcode = 3
) {
override fun decode(input: ByteBuf, cipher: StreamCipher): VariableByteOptimisedPacket {
val value = ByteArray(input.readableBytes())
input.readBytes(value)
return VariableByteOptimisedPacket(value)
}
override fun encode(input: VariableByteOptimisedPacket, output: ByteBuf, cipher: StreamCipher) {
output.writeBytes(input.value)
}
override fun getLength(input: VariableByteOptimisedPacket): Int {
return input.value.size
}
}