Chunked Transfer¶
Large payloads that exceed a single packet's practical size are split into multiple BMByteChunk objects and sent sequentially. The receiver reassembles them into the original byte array.
Reassembly¶
The receiver maintains a buffer per setId. For each incoming chunk:
- If
startByteis 0 or thesetIdis new, allocate a byte array oftotalSizebytes. - Copy
byteArrayinto the buffer at offsetstartByte. - If
startByte + chunkSize == totalSize, the transfer is complete and the assembled byte array is dispatched.
Individual chunks trigger an onChunkReceived callback. The final chunk triggers onChunkSetComplete with the fully reassembled byte array.
Primary Use Case¶
The main use of chunked transfer is delivering the control scheme XML from the game host to the controller. The game host serializes the XML string into bytes and splits it into BMByteChunk objects, each sent as the message field of a BMPacket on channel 5.