@itwin/core-common
Version:
iTwin.js components common to frontend and backend
61 lines • 2.11 kB
TypeScript
/** @packageDocumentation
* @module IpcSocket
*/
import { IpcListener, IpcSocket, IpcSocketBackend, IpcSocketFrontend, RemoveFunction } from "./IpcSocket";
import { IpcWebSocketTransport } from "./IpcWebSocketTransport";
/** @internal */
export declare enum IpcWebSocketMessageType {
Send = 0,
Push = 1,
Invoke = 2,
Response = 3,
Internal = 4,
Duplicate = 5
}
/** @internal */
export interface IpcWebSocketMessage {
type: IpcWebSocketMessageType;
request?: number;
response?: number;
channel: string;
method?: string;
data?: any[];
sequence: number;
}
/** @internal */
export declare namespace IpcWebSocketMessage {
function internal(): IpcWebSocketMessage;
function duplicate(): IpcWebSocketMessage;
function skip(message: IpcWebSocketMessage): boolean;
}
/** @internal */
export declare abstract class IpcWebSocket implements IpcSocket {
static transport: IpcWebSocketTransport;
static receivers: Set<(evt: Event, message: IpcWebSocketMessage) => void>;
protected _channels: Map<string, Set<IpcListener>>;
constructor();
abstract send(channel: string, ...data: any[]): void;
addListener(channel: string, listener: IpcListener): RemoveFunction;
removeListener(channel: string, listener: IpcListener): void;
private broadcast;
}
/** @internal */
export declare class IpcWebSocketFrontend extends IpcWebSocket implements IpcSocketFrontend {
private _nextRequest;
private _pendingRequests;
constructor();
send(channel: string, ...data: any[]): void;
invoke(channel: string, methodName: string, ...args: any[]): Promise<any>;
private dispatch;
}
/** @internal */
export declare class IpcWebSocketBackend extends IpcWebSocket implements IpcSocketBackend {
private _handlers;
private _processingQueue;
constructor();
send(channel: string, ...data: any[]): void;
handle(channel: string, handler: (event: Event, methodName: string, ...args: any[]) => Promise<any>): RemoveFunction;
private dispatch;
private processMessages;
}
//# sourceMappingURL=IpcWebSocket.d.ts.map