UNPKG

1.7 kBTypeScriptView Raw
1import { interfaces } from 'inversify';
2import { JsonRpcProxy, Emitter, Event, Channel } from '../../common';
3import { AbstractConnectionProvider } from '../../common/messaging/abstract-connection-provider';
4import { Socket } from 'socket.io-client';
5import { IWebSocket } from '../../common/messaging/web-socket-channel';
6export interface WebSocketOptions {
7 /**
8 * True by default.
9 */
10 reconnecting?: boolean;
11}
12export declare class WebSocketConnectionProvider extends AbstractConnectionProvider<WebSocketOptions> {
13 protected readonly onSocketDidOpenEmitter: Emitter<void>;
14 get onSocketDidOpen(): Event<void>;
15 protected readonly onSocketDidCloseEmitter: Emitter<void>;
16 get onSocketDidClose(): Event<void>;
17 static createProxy<T extends object>(container: interfaces.Container, path: string, arg?: object): JsonRpcProxy<T>;
18 protected readonly socket: Socket;
19 constructor();
20 protected createMainChannel(): Channel;
21 protected toIWebSocket(socket: Socket): IWebSocket;
22 openChannel(path: string, handler: (channel: Channel) => void, options?: WebSocketOptions): Promise<void>;
23 /**
24 * @param path The handler to reach in the backend.
25 */
26 protected createWebSocketUrl(path: string): string;
27 protected createHttpWebSocketUrl(path: string): string;
28 /**
29 * Creates a web socket for the given url
30 */
31 protected createWebSocket(url: string): Socket;
32 /**
33 * Path for Socket.io to make its requests to.
34 */
35 protected createSocketIoPath(url: string): string | undefined;
36 protected fireSocketDidOpen(): void;
37 protected fireSocketDidClose(): void;
38}
39//# sourceMappingURL=ws-connection-provider.d.ts.map
\No newline at end of file