(
srv: undefined | Partial<ServerOptions> | TServerInstance | number,
opts: Partial<ServerOptions> = {}
)
| 229 | opts?: Partial<ServerOptions> |
| 230 | ); |
| 231 | constructor( |
| 232 | srv: undefined | Partial<ServerOptions> | TServerInstance | number, |
| 233 | opts: Partial<ServerOptions> = {} |
| 234 | ) { |
| 235 | super(); |
| 236 | if ( |
| 237 | "object" === typeof srv && |
| 238 | srv instanceof Object && |
| 239 | !(srv as Partial<http.Server>).listen |
| 240 | ) { |
| 241 | opts = srv as Partial<ServerOptions>; |
| 242 | srv = undefined; |
| 243 | } |
| 244 | this.path(opts.path || "/socket.io"); |
| 245 | this.connectTimeout(opts.connectTimeout || 45000); |
| 246 | this.serveClient(false !== opts.serveClient); |
| 247 | this._parser = opts.parser || parser; |
| 248 | this.encoder = new this._parser.Encoder(); |
| 249 | this.opts = opts; |
| 250 | if (opts.connectionStateRecovery) { |
| 251 | opts.connectionStateRecovery = Object.assign( |
| 252 | { |
| 253 | maxDisconnectionDuration: 2 * 60 * 1000, |
| 254 | skipMiddlewares: true, |
| 255 | }, |
| 256 | opts.connectionStateRecovery |
| 257 | ); |
| 258 | this.adapter(opts.adapter || SessionAwareAdapter); |
| 259 | } else { |
| 260 | this.adapter(opts.adapter || Adapter); |
| 261 | } |
| 262 | opts.cleanupEmptyChildNamespaces = !!opts.cleanupEmptyChildNamespaces; |
| 263 | this.sockets = this.of("/"); |
| 264 | if (srv || typeof srv == "number") |
| 265 | this.attach(srv as TServerInstance | number); |
| 266 | |
| 267 | if (this.opts.cors) { |
| 268 | this._corsMiddleware = corsMiddleware(this.opts.cors); |
| 269 | } |
| 270 | } |
| 271 | |
| 272 | get _opts() { |
| 273 | return this.opts; |
nothing calls this directly
no test coverage detected