* Called when parser fully decodes a packet. * * @private
(packet: Packet)
| 267 | * @private |
| 268 | */ |
| 269 | private ondecoded(packet: Packet): void { |
| 270 | const { namespace, authPayload } = this._parseNamespace(packet); |
| 271 | const socket = this.nsps.get(namespace); |
| 272 | |
| 273 | if (!socket && packet.type === PacketType.CONNECT) { |
| 274 | this.connect(namespace, authPayload); |
| 275 | } else if ( |
| 276 | socket && |
| 277 | packet.type !== PacketType.CONNECT && |
| 278 | packet.type !== PacketType.CONNECT_ERROR |
| 279 | ) { |
| 280 | process.nextTick(function () { |
| 281 | socket._onpacket(packet); |
| 282 | }); |
| 283 | } else { |
| 284 | debug("invalid state (packet type: %s)", packet.type); |
| 285 | this.close(); |
| 286 | } |
| 287 | } |
| 288 | |
| 289 | private _parseNamespace(packet: Packet) { |
| 290 | if (this.conn.protocol !== 3) { |
nothing calls this directly
no test coverage detected