1 |
|
2 | import { Duplex } from 'stream';
|
3 | import { Disposable, Emitter, Event } from '../../common';
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 | export declare class BinaryMessagePipe implements Disposable {
|
10 | protected readonly underlyingPipe: Duplex;
|
11 | static readonly MESSAGE_START_IDENTIFIER = "<MessageStart>";
|
12 | protected dataHandler: (chunk: Uint8Array) => void;
|
13 | protected onMessageEmitter: Emitter<Uint8Array>;
|
14 | protected cachedMessageData: StreamedMessageData;
|
15 | get onMessage(): Event<Uint8Array>;
|
16 | constructor(underlyingPipe: Duplex);
|
17 | send(message: Uint8Array): void;
|
18 | protected handleChunk(chunk: Uint8Array): void;
|
19 | protected handleNewMessage(chunk: Uint8Array): void;
|
20 | protected handleMessageContentChunk(chunk: Uint8Array): void;
|
21 | protected emitCachedMessage(): void;
|
22 | /**
|
23 | * Encodes the start of a new message into a {@link Uint8Array}.
|
24 | * The message start consists of a identifier string and the length of the following message.
|
25 | * @returns the buffer contains the encoded message start
|
26 | */
|
27 | protected encodeMessageStart(message: Uint8Array): Uint8Array;
|
28 | protected get messageStartByteLength(): number;
|
29 | |
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 | protected readMessageStart(chunk: Uint8Array): number;
|
37 | dispose(): void;
|
38 | }
|
39 | interface StreamedMessageData {
|
40 | chunks: Uint8Array[];
|
41 | missingBytes: number;
|
42 | partialMessageStart?: Uint8Array;
|
43 | }
|
44 | export {};
|
45 |
|
\ | No newline at end of file |