import { Connection, type Handler, type PayloadDataType, type Parent, Payload } from './shared-connection.js'; import type { SocketAdapter } from '@akala/core'; /** * Base functionality shared by client and server * * @constructor * @public */ export declare abstract class Base = Connection> implements Parent { type: string; constructor(type: string); id: `${string}-${string}-${string}-${string}-${string}`; browser: boolean; private requestHandlers; protected connections: { [id: string | number]: Connection; }; /** * Add a handler function for a given method * * @param {String} method - name of the method to add handler for. * @param {function} handler - function to be passed params for given method. * @todo enforce handler w/ two-param callback * @public */ expose, TReplyType extends PayloadDataType>(method: string, handler: Handler): void; /** * Connected event handler * * @param {Object} socket - new socket connection * @private */ connected(socket: SocketAdapter>): void; abstract connection(socket: SocketAdapter>): Connection; /** * Disconnected event handler * * @param {Object} connection - connection object that has been closed * @private */ disconnected(connection: Connection): void; /** * Test if a handler exists for a given method * * @param {String} method - name of method * @returns {Boolean} whether or not there are any handlers for the given method * @public */ hasHandler(method: string): boolean; /** * Get handler for a given method * * @param {String} method - name of method * @returns {Array} - handler for given method * @public */ getHandler(method: string): Handler, PayloadDataType>; /** * Get a connection by id * * @param {id} id - id of the connection to get * @returns {Connection} - Connection * @public */ getConnection(id: string | number): Connection; /** * Shut down all existing connections * * @public */ hangup(): void; }