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

Method _createSocket

packages/socket.io/lib/namespace.ts:382–406  ·  view source on GitHub ↗
(
    client: Client<ListenEvents, EmitEvents, ServerSideEvents>,
    auth: Record<string, unknown>,
  )

Source from the content-addressed store, hash-verified

380 }
381
382 private async _createSocket(
383 client: Client<ListenEvents, EmitEvents, ServerSideEvents>,
384 auth: Record<string, unknown>,
385 ) {
386 const sessionId = auth.pid;
387 const offset = auth.offset;
388 if (
389 // @ts-ignore
390 this.server.opts.connectionStateRecovery &&
391 typeof sessionId === "string" &&
392 typeof offset === "string"
393 ) {
394 let session;
395 try {
396 session = await this.adapter.restoreSession(sessionId, offset);
397 } catch (e) {
398 debug("error while restoring session: %s", e);
399 }
400 if (session) {
401 debug("connection state recovered for sid %s", session.sid);
402 return new Socket(this, client, auth, session);
403 }
404 }
405 return new Socket(this, client, auth);
406 }
407
408 private _doConnect(
409 socket: Socket<ListenEvents, EmitEvents, ServerSideEvents, SocketData>,

Callers 1

_addMethod · 0.95

Calls 2

debugFunction · 0.85
restoreSessionMethod · 0.45

Tested by

no test coverage detected