* Called when: * * - the low-level engine is closed * - the parser encountered a badly formatted packet * - all sockets are disconnected * * @private
(reason: string, description?: DisconnectDescription)
| 555 | * @private |
| 556 | */ |
| 557 | private onclose(reason: string, description?: DisconnectDescription): void { |
| 558 | debug("closed due to %s", reason); |
| 559 | |
| 560 | this.cleanup(); |
| 561 | this.engine?.close(); |
| 562 | this.backoff.reset(); |
| 563 | this._readyState = "closed"; |
| 564 | this.emitReserved("close", reason, description); |
| 565 | |
| 566 | if (this._reconnection && !this.skipReconnect) { |
| 567 | this.reconnect(); |
| 568 | } |
| 569 | } |
| 570 | |
| 571 | /** |
| 572 | * Attempt a reconnection. |