1 | import RAL from './ral';
|
2 | import { Message } from './messages';
|
3 | import { Event } from './events';
|
4 | import { ContentEncoder, ContentTypeEncoder } from './encoding';
|
5 |
|
6 |
|
7 |
|
8 | export interface MessageWriter {
|
9 | |
10 |
|
11 |
|
12 | readonly onError: Event<[Error, Message | undefined, number | undefined]>;
|
13 | |
14 |
|
15 |
|
16 | readonly onClose: Event<void>;
|
17 | |
18 |
|
19 |
|
20 |
|
21 |
|
22 | write(msg: Message): Promise<void>;
|
23 | |
24 |
|
25 |
|
26 |
|
27 | end(): void;
|
28 |
|
29 | dispose(): void;
|
30 | }
|
31 | export declare namespace MessageWriter {
|
32 | function is(value: any): value is MessageWriter;
|
33 | }
|
34 | export declare abstract class AbstractMessageWriter {
|
35 | private errorEmitter;
|
36 | private closeEmitter;
|
37 | constructor();
|
38 | dispose(): void;
|
39 | get onError(): Event<[Error, Message | undefined, number | undefined]>;
|
40 | protected fireError(error: any, message?: Message, count?: number): void;
|
41 | get onClose(): Event<void>;
|
42 | protected fireClose(): void;
|
43 | private asError;
|
44 | }
|
45 | export interface MessageWriterOptions {
|
46 | charset?: RAL.MessageBufferEncoding;
|
47 | contentEncoder?: ContentEncoder;
|
48 | contentTypeEncoder?: ContentTypeEncoder;
|
49 | }
|
50 | export declare class WriteableStreamMessageWriter extends AbstractMessageWriter implements MessageWriter {
|
51 | private writable;
|
52 | private options;
|
53 | private errorCount;
|
54 | private writeSemaphore;
|
55 | constructor(writable: RAL.WritableStream, options?: RAL.MessageBufferEncoding | MessageWriterOptions);
|
56 | write(msg: Message): Promise<void>;
|
57 | private doWrite;
|
58 | private handleError;
|
59 | end(): void;
|
60 | }
|