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

Method constructor

packages/engine.io/lib/socket.ts:79–109  ·  view source on GitHub ↗
(
    id: string,
    server: BaseServer,
    transport: Transport,
    req: EngineRequest,
    protocol: number,
  )

Source from the content-addressed store, hash-verified

77 }
78
79 constructor(
80 id: string,
81 server: BaseServer,
82 transport: Transport,
83 req: EngineRequest,
84 protocol: number,
85 ) {
86 super();
87 this.id = id;
88 this.server = server;
89 this.request = req;
90 this.protocol = protocol;
91
92 // Cache IP since it might not be in the req later
93 if (req) {
94 if (req.websocket && req.websocket._socket) {
95 this.remoteAddress = req.websocket._socket.remoteAddress;
96 } else {
97 this.remoteAddress = req.connection.remoteAddress;
98 }
99 } else {
100 // TODO there is currently no way to get the IP address of the client when it connects with WebTransport
101 // see https://github.com/fails-components/webtransport/issues/114
102 }
103
104 this.pingTimeoutTimer = null;
105 this.pingIntervalTimer = null;
106
107 this.setTransport(transport);
108 this.onOpen();
109 }
110
111 /**
112 * Called upon transport considered open.

Callers

nothing calls this directly

Calls 2

setTransportMethod · 0.95
onOpenMethod · 0.95

Tested by

no test coverage detected