@push.rocks/smartsocket
Version:
Provides easy and secure websocket communication mechanisms, including server and client implementation, function call routing, connection management, and tagging.
44 lines (43 loc) • 1.72 kB
TypeScript
import * as plugins from './smartsocket.plugins.js';
import * as pluginsTyped from './smartsocket.pluginstyped.js';
import * as interfaces from './interfaces/index.js';
import { SocketConnection } from './smartsocket.classes.socketconnection.js';
import { SocketFunction } from './smartsocket.classes.socketfunction.js';
import { SocketRequest } from './smartsocket.classes.socketrequest.js';
export interface ISmartsocketConstructorOptions {
alias: string;
port?: number;
}
export declare class Smartsocket {
/**
* a unique id to detect server restarts
*/
alias: string;
smartenv: plugins.smartenv.Smartenv;
options: ISmartsocketConstructorOptions;
io: pluginsTyped.socketIo.Server;
socketConnections: plugins.lik.ObjectMap<SocketConnection>;
socketFunctions: plugins.lik.ObjectMap<SocketFunction<any>>;
socketRequests: plugins.lik.ObjectMap<SocketRequest<any>>;
eventSubject: plugins.smartrx.rxjs.Subject<interfaces.TConnectionStatus>;
private socketServer;
constructor(optionsArg: ISmartsocketConstructorOptions);
setExternalServer(serverType: 'smartexpress', serverArg: any): Promise<void>;
/**
* starts smartsocket
*/
start(): Promise<void>;
/**
* stops smartsocket
*/
stop(): Promise<void>;
/**
* allows call to specific client.
*/
clientCall<T extends plugins.typedrequestInterfaces.ITypedRequest>(functionNameArg: T['method'], dataArg: T['request'], targetSocketConnectionArg: SocketConnection): Promise<T['response']>;
addSocketFunction(socketFunction: SocketFunction<any>): void;
/**
* the standard handler for new socket connections
*/
private _handleSocketConnection;
}