(reason)
| 155 | } |
| 156 | |
| 157 | #onClose(reason) { |
| 158 | if (this.#ws) { |
| 159 | this.#ws.onclose = noop; |
| 160 | this.#ws.close(); |
| 161 | } |
| 162 | |
| 163 | clearTimeout(this.#pingTimeoutTimer); |
| 164 | clearTimeout(this.#reconnectTimer); |
| 165 | |
| 166 | if (this.connected) { |
| 167 | this.connected = false; |
| 168 | this.id = undefined; |
| 169 | super.emit("disconnect", reason); |
| 170 | } else { |
| 171 | super.emit("connect_error", reason); |
| 172 | } |
| 173 | |
| 174 | if (this.#shouldReconnect) { |
| 175 | this.#reconnectTimer = setTimeout( |
| 176 | () => this.#open(), |
| 177 | this.#opts.reconnectionDelay |
| 178 | ); |
| 179 | } |
| 180 | } |
| 181 | |
| 182 | #resetPingTimeout() { |
| 183 | clearTimeout(this.#pingTimeoutTimer); |
no test coverage detected