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

Function onWebSocket

packages/socket.io-cluster-engine/lib/engine.ts:554–574  ·  view source on GitHub ↗
(req: any, socket: any, websocket: any)

Source from the content-addressed store, hash-verified

552 }
553
554 override onWebSocket(req: any, socket: any, websocket: any) {
555 const sid = req._query.sid;
556 if (!sid || this.clients[sid]) {
557 // @ts-expect-error onWebSocket() is private
558 return super.onWebSocket(req, socket, websocket);
559 }
560
561 websocket.on("error", () => {});
562 req.websocket = websocket;
563
564 const transport = this.createTransport(req._query.transport, req);
565 const senderId = req[kSenderId];
566
567 this._tryUpgrade(
568 transport,
569 () => this._onUpgradeSuccess(sid, transport, req, senderId),
570 () => {
571 debug("upgrade failure");
572 },
573 );
574 }
575
576 private _onUpgradeSuccess(
577 sid: SessionId,

Callers

nothing calls this directly

Calls 4

debugFunction · 0.85
onWebSocketMethod · 0.80
onMethod · 0.45
createTransportMethod · 0.45

Tested by

no test coverage detected