botframework-streaming
Version:
Streaming library for the Microsoft Bot Framework
60 lines • 2 kB
TypeScript
/**
* @module botframework-streaming
*/
/**
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
import { INodeBuffer, ISocket, ITransportSender, ITransportReceiver } from '../interfaces';
/**
* Web socket based transport.
*/
export declare class WebSocketTransport implements ITransportSender, ITransportReceiver {
private ws;
private readonly _queue;
private _active;
private _activeOffset;
private _activeReceiveResolve;
private _activeReceiveReject;
private _activeReceiveCount;
/**
* Creates a new instance of the [WebSocketTransport](xref:botframework-streaming.WebSocketTransport) class.
*
* @param ws The ISocket to build this transport on top of.
*/
constructor(ws: ISocket);
/**
* Sends the given buffer out over the socket's connection.
*
* @param buffer The buffered data to send out over the connection.
* @returns A number indicating the length of the sent data if the data was successfully sent, otherwise 0.
*/
send(buffer: INodeBuffer): number;
/**
* Returns true if the transport is connected to a socket.
*
* @returns `true` if the the transport is connected and ready to send data, `false` otherwise.
*/
get isConnected(): boolean;
/**
* Close the socket this transport is connected to.
*/
close(): void;
/**
* Attempt to receive incoming data from the connected socket.
*
* @param count The number of bytes to attempt to receive.
* @returns A buffer populated with the received data.
*/
receive(count: number): Promise<INodeBuffer>;
/**
* Sets the transport to attempt to receive incoming data that has not yet arrived.
*
* @param data A buffer to store incoming data in.
*/
onReceive(data: INodeBuffer): void;
private onClose;
private onError;
private trySignalData;
}
//# sourceMappingURL=webSocketTransport.d.ts.map