/// import express from 'express'; import * as http from 'http'; import * as iof from 'io-filter'; import { Connection } from './Connection.js'; import { Session } from './Session.js'; declare type EventHandler = (payload: payloadFilter, client: Connection) => Promise; /** * Generic server object. Handle typed event communication. */ export declare class Server { static readonly UPLOADED_FILE_REGEXP: RegExp; /** * List of accepted events. */ private readonly events; private readonly app; private readonly wss; onConnectionCreated?: (connection: Connection) => Promise; /** * Builds a session object when a new connection is initiated */ sessionBuilder: (request: http.IncomingMessage) => Promise; /** * Cooldown entries */ private coolDownEntries; constructor(sessionBuilder: (request: http.IncomingMessage) => Promise); /** * On file upload */ onFileUpload(req: express.Request, res: express.Response): void; /** * Register a new client event * @param name * @param handler * @param coolDownMs * @param maxCallsPer60Seconds * @param payloadType Type of payload. If set to a string, the type of the payload should be equal to this string. Can also be set to a valid mask filter. */ registerEvent(name: string, handler: EventHandler, coolDownMs: number, maxCallsPer60Seconds: number, payloadType?: string | iof.MaskFilter): void; /** * When a new client connects * @param webSocket * @param request */ private onConnection; /** * When a new event is received * @param eventName * @param payload * @param connection */ private onConnectionEvent; /** * Cleanup stale cooldown entries */ cleanup(): void; } export {};