public interface WebSocketClient
This interface represents the minimal contract for initiating WebSocket handshakes. Implementations are expected to be thread-safe.
| Modifier and Type | Method and Description |
|---|---|
CompletableFuture<WebSocket> |
connect(URI uri,
WebSocketListener listener,
WebSocketClientConfig cfg,
HttpContext context)
Initiates an asynchronous WebSocket connection to the given target URI.
|
CompletableFuture<WebSocket> connect(URI uri, WebSocketListener listener, WebSocketClientConfig cfg, HttpContext context)
The URI must use the ws or wss scheme. This method
performs an HTTP/1.1 upgrade to the WebSocket protocol and, on success,
creates a WebSocket associated with the supplied
WebSocketListener.
The operation is fully asynchronous. The returned
CompletableFuture completes when the opening WebSocket
handshake has either succeeded or failed.
uri - target WebSocket URI, must not be null.listener - callback that receives WebSocket events, must not be null.cfg - optional per-connection configuration; if null, the
client’s default configuration is used.context - optional HTTP context for the underlying upgrade request;
may be null.WebSocket on
success, or completes exceptionally if the connection attempt
or protocol handshake fails.Copyright © 1999–2021 The Apache Software Foundation. All rights reserved.