* Called upon closing. Called by `Client`. * * @param {String} reason * @param description * @throw {Error} optional error object * * @private
(reason: DisconnectReason, description?: any)
| 741 | * @private |
| 742 | */ |
| 743 | _onclose(reason: DisconnectReason, description?: any): this | undefined { |
| 744 | if (!this.connected) return this; |
| 745 | debug("closing socket - reason %s", reason); |
| 746 | this.emitReserved("disconnecting", reason, description); |
| 747 | |
| 748 | if ( |
| 749 | this.server._opts.connectionStateRecovery && |
| 750 | RECOVERABLE_DISCONNECT_REASONS.has(reason) |
| 751 | ) { |
| 752 | debug("connection state recovery is enabled for sid %s", this.id); |
| 753 | this.adapter.persistSession({ |
| 754 | sid: this.id, |
| 755 | pid: this.pid, |
| 756 | rooms: [...this.rooms], |
| 757 | data: this.data, |
| 758 | }); |
| 759 | } |
| 760 | |
| 761 | this._cleanup(); |
| 762 | this.client._remove(this); |
| 763 | this.connected = false; |
| 764 | this.emitReserved("disconnect", reason, description); |
| 765 | return; |
| 766 | } |
| 767 | |
| 768 | /** |
| 769 | * Makes the socket leave all the rooms it was part of and prevents it from joining any other room |
no test coverage detected