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 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 | export declare class RpcProtocol {
|
32 | readonly channel: Channel;
|
33 | readonly requestHandler: RequestHandler;
|
34 | static readonly CANCELLATION_TOKEN_KEY = "add.cancellation.token";
|
35 | protected readonly pendingRequests: Map<number, Deferred<any>>;
|
36 | protected nextMessageId: number;
|
37 | protected readonly encoder: RpcMessageEncoder;
|
38 | protected readonly decoder: RpcMessageDecoder;
|
39 | protected readonly onNotificationEmitter: Emitter<{
|
40 | method: string;
|
41 | args: any[];
|
42 | }>;
|
43 | protected readonly cancellationTokenSources: Map<number, CancellationTokenSource>;
|
44 | get onNotification(): Event<{
|
45 | method: string;
|
46 | args: any[];
|
47 | }>;
|
48 | protected toDispose: DisposableCollection;
|
49 | constructor(channel: Channel, requestHandler: RequestHandler, options?: RpcProtocolOptions);
|
50 | handleMessage(message: RpcMessage): void;
|
51 | protected handleReply(id: number, value: any): void;
|
52 | protected handleReplyErr(id: number, error: any): void;
|
53 | sendRequest<T>(method: string, args: any[]): Promise<T>;
|
54 | sendNotification(method: string, args: any[]): void;
|
55 | sendCancel(requestId: number): void;
|
56 | protected handleCancel(id: number): void;
|
57 | protected handleRequest(id: number, method: string, args: any[]): Promise<void>;
|
58 | protected handleNotify(id: number, method: string, args: any[]): Promise<void>;
|
59 | }
|
60 | //# sourceMappingURL=rpc-protocol.d.ts.map |
\ | No newline at end of file |