Skip to content

Class: RequestStream ​

Wraps a WebTransport bidirectional stream carrying one MOQT request. Because a response is correlated by the stream it arrives on, nothing here needs a request id.

Constructors ​

Constructor ​

new RequestStream(biStream, events?): RequestStream

Parameters ​

biStream ​

WebTransportBidirectionalStream

events? ​

Emitter<ClientEvents>

Receives messagesent and messagereceived for every message on this stream.

Returns ​

RequestStream

Properties ​

first? ​

optional first?: ControlMessage

The message this side opened the stream with, kept so the request can be re-issued on a fresh stream when the peer migrates it with a GOAWAY (§10.4). Undefined on a peer-opened stream, which is the peer's request to re-issue, not ours.


migrated ​

migrated: boolean = false

Set when the request this stream carried has been re-issued on a new stream.


openingType? ​

optional openingType?: ControlMessageType

The type of the message that opened this stream, whichever side opened it. It is what the request on this stream is, which decides what may follow — a REQUEST_UPDATE is only valid for the types §10.9 lists.


stream ​

readonly stream: ReadableStream<ControlMessage>

Methods ​

close() ​

close(): Promise<void>

Returns ​

Promise<void>


next() ​

next(): Promise<ControlMessage | undefined>

Reads the next control message off this stream, or undefined once the peer has closed or reset it.

Takes ownership of RequestStream.stream's reader on first use, so callers must not mix next() with stream.getReader().

Returns ​

Promise<ControlMessage | undefined>


reset() ​

reset(code): Promise<void>

Cancels the request by resetting its stream with code.

Parameters ​

code ​

StreamResetCode

Returns ​

Promise<void>


send() ​

send(message): Promise<void>

Parameters ​

message ​

ControlMessage

Returns ​

Promise<void>


open() ​

static open(webTransport, first, events?): Promise<RequestStream>

Opens a new bidi stream and writes first on it.

Parameters ​

webTransport ​

WebTransport

first ​

ControlMessage

events? ​

Emitter<ClientEvents>

Returns ​

Promise<RequestStream>

Throws ​

:ProtocolViolationError If first is not one of the seven types Table 5 marks First; those are the only ones allowed to open a request stream.