UNPKG

nerdbank-streams

Version:
70 lines (69 loc) 2.73 kB
import { AcceptanceParameters } from './AcceptanceParameters'; import { ChannelOptions } from './ChannelOptions'; import { IDisposableObservable } from './IDisposableObservable'; import { MultiplexingStreamClass } from './MultiplexingStream'; import { OfferParameters } from './OfferParameters'; import { QualifiedChannelId } from './QualifiedChannelId'; export declare abstract class Channel implements IDisposableObservable { /** * The id of the channel. * @obsolete Use qualifiedId instead. */ get id(): number; /** * The party-qualified ID of the channel. */ readonly qualifiedId: QualifiedChannelId; /** * A read/write stream used to communicate over this channel. */ abstract stream: NodeJS.ReadWriteStream; /** * A promise that completes when this channel has been accepted/rejected by the remote party. */ abstract acceptance: Promise<void>; /** * A promise that completes when this channel is closed. */ abstract completion: Promise<void>; private _isDisposed; constructor(id: QualifiedChannelId); /** * Gets a value indicating whether this channel has been disposed. */ get isDisposed(): boolean; /** * Closes this channel. * @param error An optional error to send to the remote side, if this multiplexing stream is using protocol versions >= 2. */ dispose(error?: Error | null): void; } export declare class ChannelClass extends Channel { readonly name: string; private _duplex; private readonly _multiplexingStream; private readonly _acceptance; private readonly _completion; localWindowSize?: number; private remoteWindowSize?; /** * The number of bytes transmitted from here but not yet acknowledged as processed from there, * and thus occupying some portion of the full AcceptanceParameters.RemoteWindowSize. */ private remoteWindowFilled; /** A signal which indicates when the <see cref="RemoteWindowRemaining"/> is non-zero. */ private remoteWindowHasCapacity; constructor(multiplexingStream: MultiplexingStreamClass, id: QualifiedChannelId, offerParameters: OfferParameters); get stream(): NodeJS.ReadWriteStream; get acceptance(): Promise<void>; get isAccepted(): boolean; get isRejectedOrCanceled(): boolean; get completion(): Promise<void>; tryAcceptOffer(options?: ChannelOptions): boolean; tryCancelOffer(reason: any): void; onAccepted(acceptanceParameter: AcceptanceParameters): boolean; onContent(buffer: Buffer | null): void; onContentProcessed(bytesProcessed: number): void; dispose(error?: Error | null): void; private onTransmittingBytes; }