* Close ws connection. * @returns {Promise }
()
| 316 | * @returns {Promise<unknown>} |
| 317 | */ |
| 318 | close() { |
| 319 | this._failPending(new Error('BiDi connection closed before response was received')) |
| 320 | |
| 321 | const closeWebSocket = (callback) => { |
| 322 | // don't close if it's already closed |
| 323 | if (this._ws.readyState === 3) { |
| 324 | callback() |
| 325 | } else { |
| 326 | // don't notify on user-initiated shutdown ('disconnect' event) |
| 327 | this._ws.removeAllListeners('close') |
| 328 | this._ws.once('close', () => { |
| 329 | this._ws.removeAllListeners() |
| 330 | callback() |
| 331 | }) |
| 332 | this._ws.close() |
| 333 | } |
| 334 | } |
| 335 | return new Promise((fulfill, _) => { |
| 336 | closeWebSocket(fulfill) |
| 337 | }) |
| 338 | } |
| 339 | } |
| 340 | |
| 341 | /** |
nothing calls this directly
no test coverage detected