@itwin/core-common
Version:
iTwin.js components common to frontend and backend
69 lines • 2.39 kB
TypeScript
/** @packageDocumentation
* @module RpcInterface
*/
import { BeEvent } from "@itwin/core-bentley";
/** @internal */
export type RpcPushMessageListener<T> = (message: T) => void;
/** Defines a transport for push messages.
* @internal
*/
export declare abstract class RpcPushTransport {
onMessage?: (channelId: string, messageData: any) => void;
}
/** Defines a source of push messages.
* @internal
*/
export declare class RpcPushService {
/** The push service for the dedicated backend (for example, an electron or mobile app). */
static dedicated: RpcPushService;
readonly name: string;
constructor(name: string);
}
/** Defines a named stream of push messages.
* @internal
*/
export declare class RpcPushChannel<T> {
/** @internal */
static enabled: boolean;
private static _channels;
static setup(transport: RpcPushTransport): void;
private static notifySubscribers;
private _subscribers;
readonly name: string;
readonly service: RpcPushService;
get id(): string;
get enabled(): boolean;
subscribe(): RpcPushSubscription<T>;
private static formatId;
private constructor();
/** Creates a new RpcPushChannel.
* @throws IModelError if a channel with the specified name and service already exist.
*/
static create<T>(name: string, service?: RpcPushService): RpcPushChannel<T>;
/** Obtains an RpcPushChannel, creating it if one with the specified name and service does not already exists. */
static obtain<T>(name: string, service?: RpcPushService): RpcPushChannel<T>;
private static get;
private _refCount;
dispose(): void;
get isDisposed(): boolean;
}
/** Receives push messages from the backend.
* @internal
*/
export declare class RpcPushSubscription<T> {
readonly channel: RpcPushChannel<T>;
readonly onMessage: BeEvent<RpcPushMessageListener<T>>;
/** @internal */
constructor(channel: RpcPushChannel<T>);
}
/** Sends push messages to the frontend.
* @internal
*/
export declare abstract class RpcPushConnection<T> {
static for<T>(_channel: RpcPushChannel<T>, _client?: unknown): RpcPushConnection<T>;
readonly channel: RpcPushChannel<T>;
readonly client: unknown;
abstract send(messageData: T): Promise<void>;
protected constructor(channel: RpcPushChannel<T>, client: unknown);
}
//# sourceMappingURL=RpcPush.d.ts.map