123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475 |
-
-
-
- import http = require("http");
- import type { Server as HTTPSServer } from "https";
- import type { Http2SecureServer } from "http2";
- import { ServerOptions as EngineOptions, AttachOptions } from "engine.io";
- import { ExtendedError, Namespace, ServerReservedEventsMap } from "./namespace";
- import { Adapter, Room, SocketId } from "socket.io-adapter";
- import * as parser from "socket.io-parser";
- import type { Encoder } from "socket.io-parser";
- import { Socket } from "./socket";
- import type { BroadcastOperator, RemoteSocket } from "./broadcast-operator";
- import { EventsMap, DefaultEventsMap, EventParams, StrictEventEmitter, EventNames } from "./typed-events";
- declare type ParentNspNameMatchFn = (name: string, auth: {
- [key: string]: any;
- }, fn: (err: Error | null, success: boolean) => void) => void;
- declare type AdapterConstructor = typeof Adapter | ((nsp: Namespace) => Adapter);
- interface ServerOptions extends EngineOptions, AttachOptions {
- /**
- * name of the path to capture
- * @default "/socket.io"
- */
- path: string;
- /**
- * whether to serve the client files
- * @default true
- */
- serveClient: boolean;
- /**
- * the adapter to use
- * @default the in-memory adapter (https:
- */
- adapter: AdapterConstructor;
-
-
- parser: any;
-
-
- connectTimeout: number;
- }
-
- export declare class Server<ListenEvents extends EventsMap = DefaultEventsMap, EmitEvents extends EventsMap = ListenEvents, ServerSideEvents extends EventsMap = DefaultEventsMap, SocketData = any> extends StrictEventEmitter<ServerSideEvents, EmitEvents, ServerReservedEventsMap<ListenEvents, EmitEvents, ServerSideEvents, SocketData>> {
- readonly sockets: Namespace<ListenEvents, EmitEvents, ServerSideEvents, SocketData>;
-
-
- engine: any;
-
- readonly _parser: typeof parser;
-
- readonly encoder: Encoder;
-
-
- _nsps: Map<string, Namespace<ListenEvents, EmitEvents, ServerSideEvents, SocketData>>;
- private parentNsps;
- private _adapter?;
- private _serveClient;
- private opts;
- private eio;
- private _path;
- private clientPathRegex;
-
-
- _connectTimeout: number;
- private httpServer;
-
-
- constructor(opts?: Partial<ServerOptions>);
- constructor(srv?: http.Server | HTTPSServer | Http2SecureServer | number, opts?: Partial<ServerOptions>);
- constructor(srv: undefined | Partial<ServerOptions> | http.Server | HTTPSServer | Http2SecureServer | number, opts?: Partial<ServerOptions>);
-
-
- serveClient(v: boolean): this;
- serveClient(): boolean;
- serveClient(v?: boolean): this | boolean;
-
-
- _checkNamespace(name: string, auth: {
- [key: string]: any;
- }, fn: (nsp: Namespace<ListenEvents, EmitEvents, ServerSideEvents, SocketData> | false) => void): void;
-
-
- path(v: string): this;
- path(): string;
- path(v?: string): this | string;
-
-
- connectTimeout(v: number): this;
- connectTimeout(): number;
- connectTimeout(v?: number): this | number;
-
-
- adapter(): AdapterConstructor | undefined;
- adapter(v: AdapterConstructor): this;
-
-
- listen(srv: http.Server | HTTPSServer | Http2SecureServer | number, opts?: Partial<ServerOptions>): this;
-
-
- attach(srv: http.Server | HTTPSServer | Http2SecureServer | number, opts?: Partial<ServerOptions>): this;
- attachApp(app: any, opts?: Partial<ServerOptions>): void;
-
-
- private initEngine;
-
-
- private attachServe;
-
-
- private serve;
-
-
- private static sendFile;
-
-
- bind(engine: any): this;
-
-
- private onconnection;
-
-
- of(name: string | RegExp | ParentNspNameMatchFn, fn?: (socket: Socket<ListenEvents, EmitEvents, ServerSideEvents, SocketData>) => void): Namespace<ListenEvents, EmitEvents, ServerSideEvents, SocketData>;
-
-
- close(fn?: (err?: Error) => void): void;
-
-
- use(fn: (socket: Socket<ListenEvents, EmitEvents, ServerSideEvents, SocketData>, next: (err?: ExtendedError) => void) => void): this;
-
-
- to(room: Room | Room[]): BroadcastOperator<EmitEvents, SocketData>;
-
-
- in(room: Room | Room[]): BroadcastOperator<EmitEvents, SocketData>;
-
-
- except(room: Room | Room[]): BroadcastOperator<EmitEvents, SocketData>;
-
-
- send(...args: EventParams<EmitEvents, "message">): this;
-
-
- write(...args: EventParams<EmitEvents, "message">): this;
-
-
- serverSideEmit<Ev extends EventNames<ServerSideEvents>>(ev: Ev, ...args: EventParams<ServerSideEvents, Ev>): boolean;
-
-
- allSockets(): Promise<Set<SocketId>>;
-
-
- compress(compress: boolean): BroadcastOperator<EmitEvents, SocketData>;
-
-
- get volatile(): BroadcastOperator<EmitEvents, SocketData>;
-
-
- get local(): BroadcastOperator<EmitEvents, SocketData>;
-
-
- timeout(timeout: number): BroadcastOperator<EmitEvents, SocketData>;
-
-
- fetchSockets(): Promise<RemoteSocket<EmitEvents, SocketData>[]>;
-
-
- socketsJoin(room: Room | Room[]): void;
-
-
- socketsLeave(room: Room | Room[]): void;
-
-
- disconnectSockets(close?: boolean): void;
- }
- export { Socket, ServerOptions, Namespace, BroadcastOperator, RemoteSocket };
- export { Event } from "./socket";
|