1 | import { CancellationTokenSource } from '../cancellation';
|
2 | import { DisposableCollection } from '../disposable';
|
3 | import { Emitter, Event } from '../event';
|
4 | import { Deferred } from '../promise-util';
|
5 | import { Channel } from './channel';
|
6 | import { RpcMessage, RpcMessageDecoder, RpcMessageEncoder } from './rpc-message-encoder';
|
7 |
|
8 |
|
9 |
|
10 | export declare type RequestHandler = (method: string, args: any[]) => Promise<any>;
|
11 |
|
12 |
|
13 |
|
14 | export interface RpcProtocolOptions {
|
15 | |
16 |
|
17 |
|
18 | encoder?: RpcMessageEncoder;
|
19 | |
20 |
|
21 |
|
22 | decoder?: RpcMessageDecoder;
|
23 | |
24 |
|
25 |
|
26 | mode?: 'default' | 'clientOnly' | 'serverOnly';
|
27 | }
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 | export declare class RpcProtocol {
|
37 | readonly channel: Channel;
|
38 | readonly requestHandler: RequestHandler | undefined;
|
39 | static readonly CANCELLATION_TOKEN_KEY = "add.cancellation.token";
|
40 | protected readonly pendingRequests: Map<number, Deferred<any>>;
|
41 | protected nextMessageId: number;
|
42 | protected readonly encoder: RpcMessageEncoder;
|
43 | protected readonly decoder: RpcMessageDecoder;
|
44 | protected readonly mode: 'default' | 'clientOnly' | 'serverOnly';
|
45 | protected readonly onNotificationEmitter: Emitter<{
|
46 | method: string;
|
47 | args: any[];
|
48 | }>;
|
49 | protected readonly cancellationTokenSources: Map<number, CancellationTokenSource>;
|
50 | get onNotification(): Event<{
|
51 | method: string;
|
52 | args: any[];
|
53 | }>;
|
54 | protected toDispose: DisposableCollection;
|
55 | constructor(channel: Channel, requestHandler: RequestHandler | undefined, options?: RpcProtocolOptions);
|
56 | handleMessage(message: RpcMessage): void;
|
57 | protected handleReply(id: number, value: any): void;
|
58 | protected handleReplyErr(id: number, error: any): void;
|
59 | sendRequest<T>(method: string, args: any[]): Promise<T>;
|
60 | sendNotification(method: string, args: any[]): void;
|
61 | sendCancel(requestId: number): void;
|
62 | protected handleCancel(id: number): void;
|
63 | protected handleRequest(id: number, method: string, args: any[]): Promise<void>;
|
64 | protected handleNotify(method: string, args: any[], id?: number): Promise<void>;
|
65 | }
|
66 | //# sourceMappingURL=rpc-protocol.d.ts.map |
\ | No newline at end of file |