MCPcopy
hub / github.com/socketio/socket.io / constructor

Function constructor

packages/engine.io/lib/server.ts:187–237  ·  view source on GitHub ↗

* Server constructor. * * @param {Object} opts - options

(opts: ServerOptions = {})

Source from the content-addressed store, hash-verified

185 * @param {Object} opts - options
186 */
187 constructor(opts: ServerOptions = {}) {
188 super();
189
190 this.clients = {};
191 this.clientsCount = 0;
192
193 this.opts = Object.assign(
194 {
195 wsEngine: DEFAULT_WS_ENGINE,
196 pingTimeout: 20000,
197 pingInterval: 25000,
198 upgradeTimeout: 10000,
199 maxHttpBufferSize: 1e6,
200 transports: ["polling", "websocket"], // WebTransport is disabled by default
201 allowUpgrades: true,
202 httpCompression: {
203 threshold: 1024,
204 },
205 cors: false,
206 allowEIO3: false,
207 },
208 opts,
209 );
210
211 if (opts.cookie) {
212 this.opts.cookie = Object.assign(
213 {
214 name: "io",
215 path: "/",
216 httpOnly: true,
217 sameSite: "lax",
218 },
219 opts.cookie,
220 );
221 }
222
223 if (this.opts.cors) {
224 this.use(require("cors")(this.opts.cors));
225 }
226
227 if (opts.perMessageDeflate) {
228 this.opts.perMessageDeflate = Object.assign(
229 {
230 threshold: 1024,
231 },
232 opts.perMessageDeflate,
233 );
234 }
235
236 this.init();
237 }
238
239 protected abstract init(): void;
240

Callers

nothing calls this directly

Calls 2

useMethod · 0.45
initMethod · 0.45

Tested by

no test coverage detected