@itwin/core-common
Version:
iTwin.js components common to frontend and backend
52 lines • 2.63 kB
JavaScript
/*---------------------------------------------------------------------------------------------
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
/** @packageDocumentation
* @module RpcInterface
*/
import { RpcOperation } from "./rpc/core/RpcOperation";
import { RpcRegistry } from "./rpc/core/RpcRegistry";
import { RpcRoutingToken } from "./rpc/core/RpcRoutingToken";
/** RPC interface management is concerned with coordination of access and configuration for RPC interfaces.
* @beta
*/
export class RpcManager {
/** Initializes an RPC interface class.
* @note This function must be called on the frontend and on the backend for each RPC interface class used by an application.
*/
static initializeInterface(definition) {
RpcRegistry.instance.initializeRpcInterface(definition);
}
/** Terminates an RPC interface class. */
static terminateInterface(definition) {
RpcRegistry.instance.terminateRpcInterface(definition);
}
/** Returns the RPC client instance for the frontend. */
static getClientForInterface(definition, routing = RpcRoutingToken.default) {
return RpcRegistry.instance.getClientForInterface(definition, routing);
}
/** Register the RPC implementation class for the backend. */
static registerImpl(definition, implementation) {
RpcRegistry.instance.registerImpl(definition, implementation);
}
/** Supply the instance of the RPC interface implementation class for the backend (optional). */
static supplyImplInstance(definition, instance) {
RpcRegistry.instance.supplyImplInstance(definition, instance);
}
/** Unregister the RPC implementation class for the backend. */
static unregisterImpl(definition) {
RpcRegistry.instance.unregisterImpl(definition);
}
/** Describes the RPC interfaces and endpoints that are currently available from the backend.
* @note Some endpoints may be marked incompatible if the frontend expected a different interface declaration than the backend supplied. RPC operations against an incompatible interface will fail.
*/
static async describeAvailableEndpoints() {
return RpcRegistry.instance.describeAvailableEndpoints();
}
/** Configures RPC protocols that employ iModel-based routing infrastructure. */
static setIModel(props) {
RpcOperation.fallbackToken = props;
}
}
//# sourceMappingURL=RpcManager.js.map