I'm trying to read bytes from an okio source but I...
# squarelibraries
p
I'm trying to read bytes from an okio source but I have the feeling I'm doing it wrong:
Copy code
fun deSerialize(buffer: BufferedSource): Sequence<Event> {
        return generateSequence {
            while(true){
                if(buffer.request(4)){
                    break
                }
            }
            val size = buffer.readInt()
            while(true){
                if(buffer.request(size.toLong())){
                    break
                }
            }
            val eventBytes = buffer.readByteArray(size.toLong())
            protoBuf.load(Event.serializer(), eventBytes)
        }
    }
Would that be the correct approach to handle this using okio?