HomeGuidesAPI Reference
HubBlogChangelogSupport ForumLog In
API Reference

Web SDK - IChunk

Home > @rainway/web > IChunk

IChunk interface

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.

Signature:

export interface IChunk 

Properties

PropertyTypeDescription
chunksInGroupnumberThe total number of chunks in the message. If this is 1, the data field is immediately interpretable.
dataUint8ArrayThe chunk data.
groupIdnumberIdentifies 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.
indexnumberThe index of this chunk in the message (group of chunks). The first chunk has index 0. The last chunk has index chunksInGroup - 1.