Class AbstractWebSocketClient
java.lang.Object
org.springframework.web.socket.client.AbstractWebSocketClient
- All Implemented Interfaces:
WebSocketClient
- Direct Known Subclasses:
StandardWebSocketClient
Abstract base class for
WebSocketClient
implementations.- Since:
- 4.0
- Author:
- Rossen Stoyanchev
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
execute
(WebSocketHandler webSocketHandler, @Nullable WebSocketHttpHeaders headers, URI uri) Execute a handshake request to the given url and handle the resulting WebSocket session with the given handler.execute
(WebSocketHandler webSocketHandler, String uriTemplate, @Nullable Object... uriVars) Execute a handshake request to the given url and handle the resulting WebSocket session with the given handler.protected abstract CompletableFuture<WebSocketSession>
executeInternal
(WebSocketHandler webSocketHandler, HttpHeaders headers, URI uri, List<String> subProtocols, List<WebSocketExtension> extensions, Map<String, Object> attributes) Perform the actual handshake to establish a connection to the server.
-
Field Details
-
logger
protected final org.apache.commons.logging.Log logger
-
-
Constructor Details
-
AbstractWebSocketClient
public AbstractWebSocketClient()
-
-
Method Details
-
execute
public CompletableFuture<WebSocketSession> execute(WebSocketHandler webSocketHandler, String uriTemplate, @Nullable Object... uriVars) Description copied from interface:WebSocketClient
Execute a handshake request to the given url and handle the resulting WebSocket session with the given handler.- Specified by:
execute
in interfaceWebSocketClient
- Parameters:
webSocketHandler
- the session handleruriTemplate
- the url templateuriVars
- the variables to expand the template- Returns:
- a future that completes when the session is available
-
execute
public final CompletableFuture<WebSocketSession> execute(WebSocketHandler webSocketHandler, @Nullable WebSocketHttpHeaders headers, URI uri) Description copied from interface:WebSocketClient
Execute a handshake request to the given url and handle the resulting WebSocket session with the given handler.- Specified by:
execute
in interfaceWebSocketClient
- Parameters:
webSocketHandler
- the session handleruri
- the url- Returns:
- a future that completes when the session is available
-
assertUri
-
executeInternal
protected abstract CompletableFuture<WebSocketSession> executeInternal(WebSocketHandler webSocketHandler, HttpHeaders headers, URI uri, List<String> subProtocols, List<WebSocketExtension> extensions, Map<String, Object> attributes) Perform the actual handshake to establish a connection to the server.- Parameters:
webSocketHandler
- the client-side handler for WebSocket messagesheaders
- the HTTP headers to use for the handshake, with unwanted (forbidden) headers filtered out (nevernull
)uri
- the target URI for the handshake (nevernull
)subProtocols
- requested sub-protocols, or an empty listextensions
- requested WebSocket extensions, or an empty listattributes
- the attributes to associate with the WebSocketSession, i.e. viaWebSocketSession.getAttributes()
; currently always an empty map- Returns:
- the established WebSocket session wrapped in a
CompletableFuture
.
-