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