UNPKG

botframework-streaming

Version:

Streaming library for the Microsoft Bot Framework

52 lines 2.66 kB
/** * @module botframework-streaming */ /** * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. */ import { IHeader } from '../interfaces'; import { SubscribableStream } from '../subscribableStream'; import { PayloadAssembler } from '../assemblers/payloadAssembler'; /** * Orchestrates and manages streams. */ export declare class StreamManager { private readonly onCancelStream; private readonly activeAssemblers; /** * Initializes a new instance of the [StreamManager](xref:botframework-streaming.StreamManager) class. * * @param onCancelStream Function to trigger if the managed stream is cancelled. */ constructor(onCancelStream: (contentStreamAssembler: PayloadAssembler) => void); /** * Retrieves a [PayloadAssembler](xref:botframework-streaming.PayloadAssembler) with the given ID if one exists, otherwise a new instance is created and assigned the given ID. * * @param id The ID of the [PayloadAssembler](xref:botframework-streaming.PayloadAssembler) to retrieve or create. * @returns The [PayloadAssembler](xref:botframework-streaming.PayloadAssembler) with the given ID. */ getPayloadAssembler(id: string): PayloadAssembler; /** * Retrieves the [SubscribableStream](xref:botframework-streaming.SubscribableStream) from the [PayloadAssembler](xref:botframework-streaming.PayloadAssembler) this manager manages. * * @param header The Header of the [SubscribableStream](xref:botframework-streaming.SubscribableStream) to retrieve. * @returns The [SubscribableStream](xref:botframework-streaming.SubscribableStream) with the given header. */ getPayloadStream(header: IHeader): SubscribableStream; /** * Used to set the behavior of the managed [PayloadAssembler](xref:botframework-streaming.PayloadAssembler) when data is received. * * @param header The Header of the stream. * @param contentStream The [SubscribableStream](xref:botframework-streaming.SubscribableStream) to write incoming data to. * @param contentLength The amount of data to write to the contentStream. */ onReceive(header: IHeader, contentStream: SubscribableStream, contentLength: number): void; /** * Closes the [PayloadAssembler](xref:botframework-streaming.PayloadAssembler) assigned to the [SubscribableStream](xref:botframework-streaming.SubscribableStream) with the given ID. * * @param id The ID of the [SubscribableStream](xref:botframework-streaming.SubscribableStream) to close. */ closeStream(id: string): void; } //# sourceMappingURL=streamManager.d.ts.map