The createBidirectionalStream()
method of the WebTransport
interface asynchronously opens and returns a bidirectional stream.
The method returns a Promise
that resolves to a WebTransportBidirectionalStream
object, which has readable
and writable
properties that can be used to reliably read from and write to the server. "Reliable" means that transmission and order of data are guaranteed. This provides slower delivery (albeit faster than with WebSockets) than datagrams
, but is needed in situations where reliability and ordering are important, like chat applications.
The relative order in which queued bytes are emptied from created streams can be specified using the sendOrder
option. If set, queued bytes in streams with a higher send order are guaranteed to be sent before queued bytes for streams with a lower send order. If the order number is not set then the order in which bytes are sent is implementation dependent. Note however that even though bytes from higher send-order streams are sent first, they may not arrive first.
Note: This feature is available in Web Workers