UNPKG

2.16 kBTypeScriptView Raw
1import { interfaces } from 'inversify';
2import { Emitter, Event } from '../event';
3import { ConnectionHandler } from './handler';
4import { JsonRpcProxy, JsonRpcProxyFactory } from './proxy-factory';
5import { Channel, ChannelMultiplexer } from '../message-rpc/channel';
6/**
7 * Factor common logic according to `ElectronIpcConnectionProvider` and
8 * `WebSocketConnectionProvider`. This class handles channels in a somewhat
9 * generic way.
10 */
11export declare abstract class AbstractConnectionProvider<AbstractOptions extends object> {
12 /**
13 * Create a proxy object to remote interface of T type
14 * over an electron ipc connection for the given path and proxy factory.
15 */
16 static createProxy<T extends object>(container: interfaces.Container, path: string, factory: JsonRpcProxyFactory<T>): JsonRpcProxy<T>;
17 protected readonly onIncomingMessageActivityEmitter: Emitter<void>;
18 get onIncomingMessageActivity(): Event<void>;
19 /**
20 * Create a proxy object to remote interface of T type
21 * over a web socket connection for the given path and proxy factory.
22 */
23 createProxy<T extends object>(path: string, factory: JsonRpcProxyFactory<T>): JsonRpcProxy<T>;
24 /**
25 * Create a proxy object to remote interface of T type
26 * over a web socket connection for the given path.
27 *
28 * An optional target can be provided to handle
29 * notifications and requests from a remote side.
30 */
31 createProxy<T extends object>(path: string, target?: object): JsonRpcProxy<T>;
32 protected channelMultiplexer?: ChannelMultiplexer;
33 protected reconnectChannelOpeners: Array<() => Promise<void>>;
34 protected initializeMultiplexer(): void;
35 /**
36 * Install a connection handler for the given path.
37 */
38 listen(handler: ConnectionHandler, options?: AbstractOptions): void;
39 openChannel(path: string, handler: (channel: Channel) => void, options?: AbstractOptions): Promise<void>;
40 /**
41 * Create the main connection that is used for multiplexing all service channels.
42 */
43 protected abstract createMainChannel(): Channel;
44}
45//# sourceMappingURL=abstract-connection-provider.d.ts.map
\No newline at end of file