* Ensures a WebSocket API connection is open for the given connectionId * @param {string} connectionId - connection identifier * @return {promise} - resolves when the connection is open
(connectionId: string)
| 3945 | * @return {promise} - resolves when the connection is open |
| 3946 | */ |
| 3947 | private ensureWsApiConnection(connectionId: string): Promise<void> { |
| 3948 | return new Promise((resolve, reject) => { |
| 3949 | const existing = this.wsApiConnections[connectionId]; |
| 3950 | if (existing) { |
| 3951 | if (existing.readyState === WebSocket.OPEN) { |
| 3952 | resolve(); |
| 3953 | return; |
| 3954 | } |
| 3955 | if (existing.readyState === WebSocket.CONNECTING) { |
| 3956 | existing.once('open', () => resolve()); |
| 3957 | existing.once('error', (err: Error) => reject(err)); |
| 3958 | return; |
| 3959 | } |
| 3960 | } |
| 3961 | const ws = this.connectWsApi(connectionId, () => {}, () => {}); |
| 3962 | ws.once('open', () => resolve()); |
| 3963 | ws.once('error', (err: Error) => reject(err)); |
| 3964 | }); |
| 3965 | } |
| 3966 | |
| 3967 | /** |
| 3968 | * Gets the book tickers of given symbol(s) |
no test coverage detected