- Timestamp:
- 11/25/21 22:08:24 (3 years ago)
- Branches:
- master
- Children:
- 8d391a1
- Parents:
- 59329aa
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trip-planner-front/node_modules/socket.io/dist/index.d.ts
r59329aa re29cc2e 1 1 /// <reference types="node" /> 2 2 import http = require("http"); 3 import { EventEmitter } from "events";4 import { ExtendedError, Namespace } from "./namespace";3 import { ServerOptions as EngineOptions, AttachOptions } from "engine.io"; 4 import { ExtendedError, Namespace, ServerReservedEventsMap } from "./namespace"; 5 5 import { Adapter, Room, SocketId } from "socket.io-adapter"; 6 6 import * as parser from "socket.io-parser"; 7 7 import type { Encoder } from "socket.io-parser"; 8 8 import { Socket } from "./socket"; 9 import type { CookieSerializeOptions } from "cookie"; 10 import type { CorsOptions } from "cors"; 11 declare type Transport = "polling" | "websocket"; 9 import type { BroadcastOperator, RemoteSocket } from "./broadcast-operator"; 10 import { EventsMap, DefaultEventsMap, EventParams, StrictEventEmitter, EventNames } from "./typed-events"; 12 11 declare type ParentNspNameMatchFn = (name: string, auth: { 13 12 [key: string]: any; 14 13 }, fn: (err: Error | null, success: boolean) => void) => void; 15 interface EngineOptions { 16 /** 17 * how many ms without a pong packet to consider the connection closed 18 * @default 5000 19 */ 20 pingTimeout: number; 21 /** 22 * how many ms before sending a new ping packet 23 * @default 25000 24 */ 25 pingInterval: number; 26 /** 27 * how many ms before an uncompleted transport upgrade is cancelled 28 * @default 10000 29 */ 30 upgradeTimeout: number; 31 /** 32 * how many bytes or characters a message can be, before closing the session (to avoid DoS). 33 * @default 1e5 (100 KB) 34 */ 35 maxHttpBufferSize: number; 36 /** 37 * A function that receives a given handshake or upgrade request as its first parameter, 38 * and can decide whether to continue or not. The second argument is a function that needs 39 * to be called with the decided information: fn(err, success), where success is a boolean 40 * value where false means that the request is rejected, and err is an error code. 41 */ 42 allowRequest: (req: http.IncomingMessage, fn: (err: string | null | undefined, success: boolean) => void) => void; 43 /** 44 * the low-level transports that are enabled 45 * @default ["polling", "websocket"] 46 */ 47 transports: Transport[]; 48 /** 49 * whether to allow transport upgrades 50 * @default true 51 */ 52 allowUpgrades: boolean; 53 /** 54 * parameters of the WebSocket permessage-deflate extension (see ws module api docs). Set to false to disable. 55 * @default false 56 */ 57 perMessageDeflate: boolean | object; 58 /** 59 * parameters of the http compression for the polling transports (see zlib api docs). Set to false to disable. 60 * @default true 61 */ 62 httpCompression: boolean | object; 63 /** 64 * what WebSocket server implementation to use. Specified module must 65 * conform to the ws interface (see ws module api docs). Default value is ws. 66 * An alternative c++ addon is also available by installing uws module. 67 */ 68 wsEngine: string; 69 /** 70 * an optional packet which will be concatenated to the handshake packet emitted by Engine.IO. 71 */ 72 initialPacket: any; 73 /** 74 * configuration of the cookie that contains the client sid to send as part of handshake response headers. This cookie 75 * might be used for sticky-session. Defaults to not sending any cookie. 76 * @default false 77 */ 78 cookie: CookieSerializeOptions | boolean; 79 /** 80 * the options that will be forwarded to the cors module 81 */ 82 cors: CorsOptions; 83 /** 84 * whether to enable compatibility with Socket.IO v2 clients 85 * @default false 86 */ 87 allowEIO3: boolean; 88 } 89 interface AttachOptions { 90 /** 91 * name of the path to capture 92 * @default "/engine.io" 93 */ 94 path: string; 95 /** 96 * destroy unhandled upgrade requests 97 * @default true 98 */ 99 destroyUpgrade: boolean; 100 /** 101 * milliseconds after which unhandled requests are ended 102 * @default 1000 103 */ 104 destroyUpgradeTimeout: number; 105 } 106 interface EngineAttachOptions extends EngineOptions, AttachOptions { 107 } 108 interface ServerOptions extends EngineAttachOptions { 14 declare type AdapterConstructor = typeof Adapter | ((nsp: Namespace) => Adapter); 15 interface ServerOptions extends EngineOptions, AttachOptions { 109 16 /** 110 17 * name of the path to capture … … 121 28 * @default the in-memory adapter (https://github.com/socketio/socket.io-adapter) 122 29 */ 123 adapter: any;30 adapter: AdapterConstructor; 124 31 /** 125 32 * the parser to use … … 133 40 connectTimeout: number; 134 41 } 135 export declare class Server extends EventEmitter { 136 readonly sockets: Namespace; 42 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>> { 43 readonly sockets: Namespace<ListenEvents, EmitEvents, ServerSideEvents, SocketData>; 44 /** 45 * A reference to the underlying Engine.IO server. 46 * 47 * Example: 48 * 49 * <code> 50 * const clientsCount = io.engine.clientsCount; 51 * </code> 52 * 53 */ 54 engine: any; 137 55 /** @private */ 138 56 readonly _parser: typeof parser; … … 142 60 * @private 143 61 */ 144 _nsps: Map<string, Namespace >;62 _nsps: Map<string, Namespace<ListenEvents, EmitEvents, ServerSideEvents>>; 145 63 private parentNsps; 146 64 private _adapter?; … … 148 66 private opts; 149 67 private eio; 150 private engine;151 68 private _path; 152 69 private clientPathRegex; … … 187 104 _checkNamespace(name: string, auth: { 188 105 [key: string]: any; 189 }, fn: (nsp: Namespace | false) => void): void;106 }, fn: (nsp: Namespace<ListenEvents, EmitEvents, ServerSideEvents> | false) => void): void; 190 107 /** 191 108 * Sets the client serving path. … … 213 130 * @public 214 131 */ 215 adapter(): typeof Adapter | undefined; 216 adapter(v: typeof Adapter): this; 217 adapter(v?: typeof Adapter): typeof Adapter | undefined | this; 132 adapter(): AdapterConstructor | undefined; 133 adapter(v: AdapterConstructor): this; 218 134 /** 219 135 * Attaches socket.io to a server or port. … … 234 150 */ 235 151 attach(srv: http.Server | number, opts?: Partial<ServerOptions>): this; 152 attachApp(app: any, opts?: Partial<ServerOptions>): void; 236 153 /** 237 154 * Initialize engine … … 287 204 * @public 288 205 */ 289 of(name: string | RegExp | ParentNspNameMatchFn, fn?: (socket: Socket ) => void): Namespace;206 of(name: string | RegExp | ParentNspNameMatchFn, fn?: (socket: Socket<ListenEvents, EmitEvents, ServerSideEvents, SocketData>) => void): Namespace<ListenEvents, EmitEvents, ServerSideEvents>; 290 207 /** 291 208 * Closes server connection … … 301 218 * @public 302 219 */ 303 use(fn: (socket: Socket , next: (err?: ExtendedError) => void) => void): this;220 use(fn: (socket: Socket<ListenEvents, EmitEvents, ServerSideEvents, SocketData>, next: (err?: ExtendedError) => void) => void): this; 304 221 /** 305 222 * Targets a room when emitting. 306 223 * 224 * @param room 225 * @return self 226 * @public 227 */ 228 to(room: Room | Room[]): BroadcastOperator<EmitEvents>; 229 /** 230 * Targets a room when emitting. 231 * 232 * @param room 233 * @return self 234 * @public 235 */ 236 in(room: Room | Room[]): BroadcastOperator<EmitEvents>; 237 /** 238 * Excludes a room when emitting. 239 * 307 240 * @param name 308 241 * @return self 309 242 * @public 310 243 */ 311 to(name: Room): this; 312 /** 313 * Targets a room when emitting. 314 * 315 * @param name 316 * @return self 317 * @public 318 */ 319 in(name: Room): this; 244 except(name: Room | Room[]): BroadcastOperator<EmitEvents>; 320 245 /** 321 246 * Sends a `message` event to all clients. … … 324 249 * @public 325 250 */ 326 send(...args: readonly any[]): this;251 send(...args: EventParams<EmitEvents, "message">): this; 327 252 /** 328 253 * Sends a `message` event to all clients. … … 331 256 * @public 332 257 */ 333 write(...args: readonly any[]): this; 258 write(...args: EventParams<EmitEvents, "message">): this; 259 /** 260 * Emit a packet to other Socket.IO servers 261 * 262 * @param ev - the event name 263 * @param args - an array of arguments, which may include an acknowledgement callback at the end 264 * @public 265 */ 266 serverSideEmit<Ev extends EventNames<ServerSideEvents>>(ev: Ev, ...args: EventParams<ServerSideEvents, Ev>): boolean; 334 267 /** 335 268 * Gets a list of socket ids. … … 345 278 * @public 346 279 */ 347 compress(compress: boolean): this;280 compress(compress: boolean): BroadcastOperator<EmitEvents>; 348 281 /** 349 282 * Sets a modifier for a subsequent event emission that the event data may be lost if the client is not ready to … … 354 287 * @public 355 288 */ 356 get volatile(): this;289 get volatile(): BroadcastOperator<EmitEvents>; 357 290 /** 358 291 * Sets a modifier for a subsequent event emission that the event data will only be broadcast to the current node. … … 361 294 * @public 362 295 */ 363 get local(): this; 296 get local(): BroadcastOperator<EmitEvents>; 297 /** 298 * Returns the matching socket instances 299 * 300 * @public 301 */ 302 fetchSockets(): Promise<RemoteSocket<EmitEvents>[]>; 303 /** 304 * Makes the matching socket instances join the specified rooms 305 * 306 * @param room 307 * @public 308 */ 309 socketsJoin(room: Room | Room[]): void; 310 /** 311 * Makes the matching socket instances leave the specified rooms 312 * 313 * @param room 314 * @public 315 */ 316 socketsLeave(room: Room | Room[]): void; 317 /** 318 * Makes the matching socket instances disconnect 319 * 320 * @param close - whether to close the underlying connection 321 * @public 322 */ 323 disconnectSockets(close?: boolean): void; 364 324 } 365 export { Socket, ServerOptions, Namespace };325 export { Socket, ServerOptions, Namespace, BroadcastOperator, RemoteSocket };
Note:
See TracChangeset
for help on using the changeset viewer.