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
Promisethat resolves with statistics aggregated across all of theWebTransportSendStreamandWebTransportDatagramsWritableobjects 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 again the precise way bandwidth is divided between groups depends on the implementation.
A WebTransportSendGroup is created using the createSendGroup() method of the WebTransport interface.
You can then associate it with a WebTransportDatagramsWritable or WebTransportSendStream by passing it as the sendGroup option when the object is created — see WebTransport.createUnidirectionalStream(), WebTransport.createBidirectionalStream(), and WebTransportDatagramDuplexStream.createWritable() — or by setting the object's sendGroup property afterwards, for example WebTransportDatagramsWritable.sendGroup.
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 so that their relative priority can be compared:
const sendGroup = transport.createSendGroup();
const stream = await transport.createUnidirectionalStream({
sendGroup,
sendOrder: 1,
});
const datagrams = transport.datagrams.createWritable({
sendGroup,
sendOrder: 2,
});
// Queued bytes for datagrams are sent ahead of those for stream, as the
// two share a send group and datagrams has been given the higher sendOrder.
Specifications
| Specification |
|---|
| WebTransport> # webtransportsendgroup> |