MCPcopy Create free account
hub / github.com/socketio/socket.io / _createSocket

Method _createSocket

lib/namespace.ts:360–384  ·  view source on GitHub ↗
(
    client: Client<ListenEvents, EmitEvents, ServerSideEvents>,
    auth: Record<string, unknown>
  )

Source from the content-addressed store, hash-verified

358 }
359
360 private async _createSocket(
361 client: Client<ListenEvents, EmitEvents, ServerSideEvents>,
362 auth: Record<string, unknown>
363 ) {
364 const sessionId = auth.pid;
365 const offset = auth.offset;
366 if (
367 // @ts-ignore
368 this.server.opts.connectionStateRecovery &&
369 typeof sessionId === "string" &&
370 typeof offset === "string"
371 ) {
372 let session;
373 try {
374 session = await this.adapter.restoreSession(sessionId, offset);
375 } catch (e) {
376 debug("error while restoring session: %s", e);
377 }
378 if (session) {
379 debug("connection state recovered for sid %s", session.sid);
380 return new Socket(this, client, auth, session);
381 }
382 }
383 return new Socket(this, client, auth);
384 }
385
386 private _doConnect(
387 socket: Socket<ListenEvents, EmitEvents, ServerSideEvents, SocketData>,

Callers 1

_addMethod · 0.95

Calls 1

restoreSessionMethod · 0.80

Tested by

no test coverage detected