(contexts: string[])
| 285 | clearTimeout(this.reconnectTimer); |
| 286 | this.reconnectTimer = null; |
| 287 | } |
| 288 | this.clearHandshakeTimer(); |
| 289 | // If a connect handshake is still in flight, reject it so callers |
| 290 | // awaiting connect() don't hang forever. |
| 291 | if (this.abortHandshake) { |
| 292 | this.abortHandshake(new Error('disconnected')); |
| 293 | } |
| 294 | if (this.ws) { |
| 295 | this.ws.close(); |
| 296 | this.ws = null; |
| 297 | } |
| 298 | this.stopPing(); |
| 299 | this.connected = false; |
| 300 | } |
| 301 | |
| 302 | /** |
| 303 | * Holds the socket open for this caller. The zero-to-one transition calls |
| 304 | * connect(); every subsequent call increments an internal refcount without |
| 305 | * creating a second socket. Call release() when the caller no longer needs |
| 306 | * the connection. Callers must pair every acquire with exactly one release. |
| 307 | */ |
| 308 | async acquire(): Promise<void> { |
| 309 | this.acquireCount++; |
no test coverage detected