UNPKG

2.31 kBTypeScriptView Raw
1import { interfaces } from 'inversify';
2import { Channel, RpcProxy, RpcProxyFactory } from '../../common';
3import { ChannelMultiplexer } from '../../common/message-rpc/channel';
4import { ConnectionSource } from './connection-source';
5export declare const LocalConnectionProvider: unique symbol;
6export declare const RemoteConnectionProvider: unique symbol;
7export declare namespace ServiceConnectionProvider {
8 type ConnectionHandler = (path: String, channel: Channel) => void;
9}
10/**
11 * This class manages the channels for remote services in the back end
12 */
13export declare class ServiceConnectionProvider {
14 static createProxy<T extends object>(container: interfaces.Container, path: string, arg?: object): RpcProxy<T>;
15 static createLocalProxy<T extends object>(container: interfaces.Container, path: string, arg?: object): RpcProxy<T>;
16 static createHandler(container: interfaces.Container, path: string, arg?: object): void;
17 protected readonly channelHandlers: Map<string, ServiceConnectionProvider.ConnectionHandler>;
18 /**
19 * Create a proxy object to remote interface of T type
20 * over a web socket connection for the given path and proxy factory.
21 */
22 createProxy<T extends object>(path: string, factory: RpcProxyFactory<T>): RpcProxy<T>;
23 /**
24 * Create a proxy object to remote interface of T type
25 * over a web socket connection for the given path.
26 *
27 * An optional target can be provided to handle
28 * notifications and requests from a remote side.
29 */
30 createProxy<T extends object>(path: string, target?: object): RpcProxy<T>;
31 protected channelMultiplexer: ChannelMultiplexer;
32 private channelReadyDeferred;
33 protected get channelReady(): Promise<void>;
34 init(): void;
35 protected connectionSource: ConnectionSource;
36 /**
37 * This method must be invoked by subclasses when they have created the main channel.
38 * @param mainChannel
39 */
40 protected handleChannelCreated(channel: Channel): void;
41 handleChannelClosed(channel: Channel): void;
42 /**
43 * Install a connection handler for the given path.
44 */
45 listen(path: string, handler: ServiceConnectionProvider.ConnectionHandler, reconnect: boolean): void;
46 private openChannel;
47}
48//# sourceMappingURL=service-connection-provider.d.ts.map
\No newline at end of file