MCPcopy Index your code
hub / github.com/socketio/socket.io / connect

Method connect

lib/client.ts:117–145  ·  view source on GitHub ↗

* Connects a client to a namespace. * * @param {String} name - the namespace * @param {Object} auth - the auth parameters * @private

(name: string, auth: Record<string, unknown> = {})

Source from the content-addressed store, hash-verified

115 * @private
116 */
117 private connect(name: string, auth: Record<string, unknown> = {}): void {
118 if (this.server._nsps.has(name)) {
119 debug("connecting to namespace %s", name);
120 return this.doConnect(name, auth);
121 }
122
123 this.server._checkNamespace(
124 name,
125 auth,
126 (
127 dynamicNspName:
128 | Namespace<ListenEvents, EmitEvents, ServerSideEvents, SocketData>
129 | false
130 ) => {
131 if (dynamicNspName) {
132 this.doConnect(name, auth);
133 } else {
134 debug("creation of namespace %s was denied", name);
135 this._packet({
136 type: PacketType.CONNECT_ERROR,
137 nsp: name,
138 data: {
139 message: "Invalid namespace",
140 },
141 });
142 }
143 }
144 );
145 }
146
147 /**
148 * Connects a client to a namespace.

Callers 5

ondecodedMethod · 0.95
onconnectionMethod · 0.95
socket.tsFile · 0.45
server-close.tsFile · 0.45

Calls 3

doConnectMethod · 0.95
_packetMethod · 0.95
_checkNamespaceMethod · 0.80

Tested by

no test coverage detected