A part of a chunked message.
Certain WebRTC implementations cause large packets (>64kB or >256kB) on DataChannels to be dropped, clipped, or split down the middle (rendering their parts individually invalid). To sidestep this, Rainway peers chunk large messages into small enough units whose
data fields are reassembled by the remote peer.
A receiver stores these chunks, and reinterprets the concatenated data once all parts have been received. (The
index values run from 0 to
chunksInGroup - 1.)
On the Arbitrary channel, reassembled messages are sent to the application, and this struct is in fact the body of ArbitraryDatagram. (A short enough piece of arbitrary data is sent as a group of one chunk.)
On the Media channel, reassembled messages are interpreted as MediaDatagram and fed back into the message handler, and chunks occur as the MediaChunk of the MediaBody union.
export interface IChunk
|chunksInGroup||number||The total number of chunks in the message. If this is 1, the |
|data||Uint8Array||The chunk data.|
|groupId||number||Identifies the message (= group of chunks) this chunk is a part of. Both parties should be prepared for this ID to roll over from 0xFFFF back to 0, as more than 2^16 chunk-groups may be sent in one session.|
|index||number||The index of this chunk in the message (group of chunks). The first chunk has index 0. The last chunk has index |