StreamManager class

Orchestrates and manages streams.

Constructors

StreamManager((contentStreamAssembler: PayloadAssembler) => void)

Initializes a new instance of the StreamManager class.

Methods

closeStream(string)

Closes the PayloadAssembler assigned to the SubscribableStream with the given ID.

getPayloadAssembler(string)

Retrieves a PayloadAssembler with the given ID if one exists, otherwise a new instance is created and assigned the given ID.

getPayloadStream(IHeader)

Retrieves the SubscribableStream from the PayloadAssembler this manager manages.

onReceive(IHeader, SubscribableStream, number)

Used to set the behavior of the managed PayloadAssembler when data is received.

Constructor Details

StreamManager((contentStreamAssembler: PayloadAssembler) => void)

Initializes a new instance of the StreamManager class.

new StreamManager(onCancelStream: (contentStreamAssembler: PayloadAssembler) => void)

Parameters

onCancelStream

(contentStreamAssembler: PayloadAssembler) => void

Function to trigger if the managed stream is cancelled.

Method Details

closeStream(string)

Closes the PayloadAssembler assigned to the SubscribableStream with the given ID.

function closeStream(id: string)

Parameters

id

string

The ID of the SubscribableStream to close.

getPayloadAssembler(string)

Retrieves a PayloadAssembler with the given ID if one exists, otherwise a new instance is created and assigned the given ID.

function getPayloadAssembler(id: string): PayloadAssembler

Parameters

id

string

The ID of the PayloadAssembler to retrieve or create.

Returns

The PayloadAssembler with the given ID.

getPayloadStream(IHeader)

Retrieves the SubscribableStream from the PayloadAssembler this manager manages.

function getPayloadStream(header: IHeader): SubscribableStream

Parameters

header
IHeader

The Header of the SubscribableStream to retrieve.

Returns

The SubscribableStream with the given header.

onReceive(IHeader, SubscribableStream, number)

Used to set the behavior of the managed PayloadAssembler when data is received.

function onReceive(header: IHeader, contentStream: SubscribableStream, contentLength: number)

Parameters

header
IHeader

The Header of the stream.

contentStream
SubscribableStream

The SubscribableStream to write incoming data to.

contentLength

number

The amount of data to write to the contentStream.