* Connects a client to a namespace. * * @param {String} name - the namespace * @param {Object} auth - the auth parameters * @private
(name: string, auth: Record<string, unknown> = {})
| 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. |
no test coverage detected