ws-rmi
Version:
A Remote Method Invocation implementation written in JavaScript utilising the WebSocket protocol
52 lines (51 loc) • 1.66 kB
TypeScript
import { Logger } from "./types/Logger";
/**
* Represents common configuration that should be shared between an RMI client and exposed remote RMI functions.
*/
declare type RMIManagerConfig = {
/**
* The logger to be used by both the RMI client and exposed remote RMI functions.
*/
logger: Logger;
};
/**
* The core class for handling RMI connections. This can be used to invoke remote functions or expose functions to
* the remote.
*
* NOTE: As WebSockets are bidirectional, "client" and "remote" are arbitrary. A browser can be both client and remote
* if it both calls functions on a server while also exposing functions to the server.
*/
export declare class RMIManager {
/**
* The WebSocket connection to use to perform RMI tasks.
*
* @private
*/
private readonly _ws;
/**
* The configuration to apply to the RMI connections.
*
* @private
*/
private readonly _config;
/**
* Constructs a new manager instance.
*
* @param ws The WebSocket connection to use to perform RMI tasks. NOTE: This should be an active connection!
* @param config Configuration to be applied.
*/
constructor(ws: WebSocket, config?: RMIManagerConfig);
get ws(): WebSocket;
get config(): RMIManagerConfig;
/**
* Constructs a client interface to use to invoke remote functions.
*/
getRemote<T extends object>(): T;
/**
* Exposes the given functions to be able to be invoked by the client.
*
* @param functions An object (generally a class) that will be exposed.
*/
exposeFunctions(functions: object): void;
}
export {};