WebTransportSendGroup

Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.

Note: This feature is available in Web Workers.

The WebTransportSendGroup interface of the WebTransport API represents a group of streams and datagrams, within which relative send priority is determined by the sendOrder value of each member.

WebTransportSendGroup is a transferable object.

Instance methods

getStats()

Returns a Promise that resolves with an object containing statistics aggregated across all of the WebTransportSendStream and WebTransportDatagramsWritable objects currently associated with this group.

Description

Unlike for WritableStream instances, for which the priority at which bytes are sent on different streams is implementation-dependent, a WebTransportDatagramsWritable or WebTransportSendStream allows you to set the priority at which bytes will be sent on each instance relative to others in the same sendGroup. A send group is created using the createSendGroup() method, and the relative priority is defined by the sendOrder property of WebTransportDatagramsWritable or WebTransportSendStream instances. Different groups are expected to be treated as equals for the purposes of bandwidth allocation — though the precise way bandwidth is divided between groups is implementation-defined.

A WebTransportSendGroup is created using the createSendGroup() method of the WebTransport interface. You can then associate it with a WebTransportDatagramsWritable or WebTransportSendStream by:

Examples

Basic usage

The example below creates a send group, then associates a unidirectional stream and the connection's outgoing datagram stream with it, giving each a sendOrder. Bytes on the datagram stream will be prioritized ahead of any bytes on the unidirectional stream, because they are both in the same sendGroup and the datagram stream has a higher sendOrder.

js
const sendGroup = transport.createSendGroup();

const stream = await transport.createUnidirectionalStream({
  sendGroup,
  sendOrder: 1,
});

const datagrams = transport.datagrams.createWritable({
  sendGroup,
  sendOrder: 2,
});

Specifications

Specification
WebTransport
# webtransportsendgroup

Browser compatibility

See also