If I have a length-prefixed protocol, how can I us...
# ktor
r
If I have a length-prefixed protocol, how can I use bytepacketbuilder to first build a temp packet, then count the length and then really write it ?
a
You can get a size of written bytes from a
BytePacketBuilder
:
Copy code
val builder = BytePacketBuilder().apply {
    writeByte(1)
    writeFloat(1.0f)
}

println(builder.size)
r
yes and then reset, write size and then write out the rest