I'm not sure how to do that. I'm using 3.0-alpha.1...
# squarelibraries
l
I'm not sure how to do that. I'm using 3.0-alpha.1 and the documentation isn't adapted for v3.0 yet. My concrete use case looks like this:
Copy code
val buffer = Buffer() // gets filled until a specific condition
val packetList = listOf(/*a list of bytearrays aka packets*)

packetList.forEach { packet ->
	fun parse(buffer, packet) {
		buffer.write(packet)
		while (size != 0L) {
		  // do some read and skip operations
		  // need to remove 4 bytes from end of buffer, then return from parse and write the next packet until specific condition occurs
		}
    }
}
What I could do:
Copy code
while (size != 0L) {
    ...
	val tmpBuffer = Buffer()
	buffer.copyTo(tmpBuffer, consumableRestOfBytes)
	
	buffer.clear()
	buffer.write(tmpBuffer.readByteArray())
	
	return
...
But this might happen multiple times and it doesn't seem done properly. Maybe I could achieve this in a different way. Could you or someone else have a look please?