1 | import { WriteBuffer } from '../message-rpc';
|
2 | import { AbstractChannel } from '../message-rpc/channel';
|
3 | /**
|
4 | * A channel that manages the main websocket connection between frontend and backend. All service channels
|
5 | * are reusing this main channel. (multiplexing). An {@link IWebSocket} abstraction is used to keep the implementation
|
6 | * independent of the actual websocket implementation and its execution context (backend vs. frontend).
|
7 | */
|
8 | export declare class WebSocketChannel extends AbstractChannel {
|
9 | protected readonly socket: IWebSocket;
|
10 | static wsPath: string;
|
11 | constructor(socket: IWebSocket);
|
12 | getWriteBuffer(): WriteBuffer;
|
13 | }
|
14 | /**
|
15 | * An abstraction that enables reuse of the `{class in the frontend and backend
WebSocketChannel} |
16 | * independent of the actual underlying socket implementation.
|
17 | */
|
18 | export interface IWebSocket {
|
19 | /**
|
20 | * Sends the given message over the web socket in binary format.
|
21 | * @param message The binary message.
|
22 | */
|
23 | send(message: Uint8Array): void;
|
24 | /**
|
25 | * Closes the websocket from the local side.
|
26 | */
|
27 | close(): void;
|
28 | /**
|
29 | * The connection state of the web socket.
|
30 | */
|
31 | isConnected(): boolean;
|
32 | /**
|
33 | * Listener callback to handle incoming messages.
|
34 | * @param cb The callback.
|
35 | */
|
36 | onMessage(cb: (message: Uint8Array) => void): void;
|
37 | /**
|
38 | * Listener callback to handle socket errors.
|
39 | * @param cb The callback.
|
40 | */
|
41 | onError(cb: (reason: any) => void): void;
|
42 | /**
|
43 | * Listener callback to handle close events (Remote side).
|
44 | * @param cb The callback.
|
45 | */
|
46 | onClose(cb: (reason: string, code?: number) => void): void;
|
47 | }
|
48 | //# sourceMappingURL=web-socket-channel.d.ts.map |
\ | No newline at end of file |