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
protected ListenableFuture<WebSocketSession>
doHandshakeInternal
(WebSocketHandler webSocketHandler, HttpHeaders headers, URI uri, List<String> subProtocols, List<WebSocketExtension> extensions, Map<String, Object> attributes) Deprecated, for removal: This API element is subject to removal in a future version.execute
(WebSocketHandler webSocketHandler, String uriTemplate, Object... uriVars) Execute a handshake request to the given url and handle the resulting WebSocket session with the given handler.execute
(WebSocketHandler webSocketHandler, WebSocketHttpHeaders headers, URI uri) 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.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.web.socket.client.WebSocketClient
doHandshake, doHandshake
-
Field Details
-
logger
-
-
Constructor Details
-
AbstractWebSocketClient
public AbstractWebSocketClient()
-
-
Method Details
-
execute
public CompletableFuture<WebSocketSession> execute(WebSocketHandler webSocketHandler, String uriTemplate, 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
-
doHandshakeInternal
@Deprecated(since="6.0", forRemoval=true) protected ListenableFuture<WebSocketSession> doHandshakeInternal(WebSocketHandler webSocketHandler, HttpHeaders headers, URI uri, List<String> subProtocols, List<WebSocketExtension> extensions, Map<String, Object> attributes) Deprecated, for removal: This API element is subject to removal in a future version.as of 6.0, in favor ofexecuteInternal(WebSocketHandler, HttpHeaders, URI, List, List, Map)
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
ListenableFuture
.
-
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
.
-
executeInternal(WebSocketHandler, HttpHeaders, URI, List, List, Map)