Let's assume I have an Enumerator[Array[Byte]] producing chunks of byte arrays of variable size (say POST body accepted in controller)
And I know this streams actually contains packets of data where each packet is:
- 4 bytes representing integer denoting the size of the packet body size in bytes
- packet body of that size
Each packet can have different body size.
How do we implement an Enumeratee that transforms initial stream into stream of byte arrays where each array is a packet body.
Simplified example with ints (first comes int denoting packet body size):
List(1, 2, 3), List(4, 5), List(6), List(2, 8), List(9) -> List(2) List(4, 5 ,6), List(8, 9)