Connect to the WebSocket server. Returns a future that completes when connected. If already connecting/connected, returns the existing future.
(int backoffDelay)
| 248 | * If already connecting/connected, returns the existing future. |
| 249 | */ |
| 250 | public CompletableFuture<Boolean> connect(int backoffDelay) { |
| 251 | if (this.startedConnecting.compareAndSet(false, true)) { |
| 252 | if (backoffDelay > 0) { |
| 253 | CompletableFuture.delayedExecutor(backoffDelay, |
| 254 | java.util.concurrent.TimeUnit.MILLISECONDS) |
| 255 | .execute(this::createConnection); |
| 256 | } else { |
| 257 | Exchange.VIRTUAL_EXECUTOR.execute(this::createConnection); |
| 258 | } |
| 259 | } |
| 260 | return this.connected; |
| 261 | } |
| 262 | |
| 263 | private void createConnection() { |
| 264 | try { |
no outgoing calls