import * as schema from '@stencila/schema'; import { Executor, Claims } from './Executor'; import { JsonRpcRequest } from './JsonRpcRequest'; import { JsonRpcResponse } from './JsonRpcResponse'; import { Addresses } from './Transports'; /** * A base server class that passes JSON-RPC requests * from `Client`s to a `Executor`. */ export declare abstract class Server { /** * The executor that this server dispatches to. */ protected executor?: Executor; constructor(executor?: Executor); /** * Get the addresses of this server. * * A server will usually on have one address type (e.g. `http`, `ws`) * but may have more than one address for each type. */ abstract addresses(): Promise; /** * Send a notification to one or more clients. * * @param level The notification level e.g. `info`, `error` * @param message The notification message * @param node The node to which this notification relates e.g. a `SoftwareSession` * @param clients The ids of the clients to send the notification to. If missing send to all clients. * * @see {@link Executor.notify} * @see {@link Client.notify} */ notify(level: string, message: string, node?: schema.Node, clients?: string[]): void; /** * Receive a request or notification * * @param request A JSON-RPC request from a client * @param claims An object representing the claims for the request, * usually a from a JWT payload * @param stringify Should the response be stringified? * @returns If receiving a request then a JSON-RPC response as an * object or string (default). * If receiving a notification then nothing is returned. */ protected receive(request: string | JsonRpcRequest, claims?: Claims, stringify?: boolean): Promise; /** * Start the server * * When overriding this method, derived classes should * call this method, or ensure that `this.executor` is set themselves. */ start(executor: Executor): Promise; /** * Stop the server * * Derived classes may override this method. */ stop(): Promise; }