Top Description Fields Constructors Methods
org.springframework.web.socket.client

public abstract Class AbstractWebSocketClient

extends Object
implements WebSocketClient
Class Inheritance
All Implemented Interfaces
org.springframework.web.socket.client.WebSocketClient
Known Direct Subclasses
org.springframework.web.socket.client.standard.StandardWebSocketClient
Imports
java.net.URI, java.util.Collections, .List, .Map, .Set, java.util.concurrent.CompletableFuture, org.apache.commons.logging.Log, .LogFactory, org.springframework.http.HttpHeaders, org.springframework.lang.Nullable, org.springframework.util.Assert, org.springframework.web.socket.WebSocketExtension, .WebSocketHandler, .WebSocketHttpHeaders, .WebSocketSession, org.springframework.web.util.UriComponentsBuilder

Abstract base class for WebSocketClient implementations.
Author
Rossen Stoyanchev
Since
4.0

Field Summary

Modifier and TypeField and Description
protected final Log
private static final Set<String>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected void
protected ListenableFuture<WebSocketSession>

Returns:

the established WebSocket session wrapped in a ListenableFuture.
doHandshakeInternal
(WebSocketHandler
the client-side handler for WebSocket messages
webSocketHandler
,
HttpHeaders
the HTTP headers to use for the handshake, with unwanted (forbidden) headers filtered out (never null)
headers
,
URI
the target URI for the handshake (never null)
uri
,
List<String>
requested sub-protocols, or an empty list
subProtocols
,
List<WebSocketExtension>
requested WebSocket extensions, or an empty list
extensions
,
Map<String, Object>
the attributes to associate with the WebSocketSession, i.e. via WebSocketSession#getAttributes(); currently always an empty map.
attributes
)
Deprecated since 6.0. as of 6.0, in favor of executeInternal(WebSocketHandler, HttpHeaders, URI, List, List, Map)

Perform the actual handshake to establish a connection to the server.

public CompletableFuture<WebSocketSession>
execute(WebSocketHandler
the session handler
webSocketHandler
,
String
the url template
uriTemplate
,
Object...
the variables to expand the template
uriVars
)

Implements org.springframework.web.socket.client.WebSocketClient.execute.

Execute a handshake request to the given url and handle the resulting WebSocket session with the given handler.

public final CompletableFuture<WebSocketSession>
execute(WebSocketHandler
the session handler
webSocketHandler
,
WebSocketHttpHeaders headers, URI
the url
uri
)

Implements org.springframework.web.socket.client.WebSocketClient.execute.

Execute a handshake request to the given url and handle the resulting WebSocket session with the given handler.

protected abstract CompletableFuture<WebSocketSession>

Returns:

the established WebSocket session wrapped in a CompletableFuture.
executeInternal
(WebSocketHandler
the client-side handler for WebSocket messages
webSocketHandler
,
HttpHeaders
the HTTP headers to use for the handshake, with unwanted (forbidden) headers filtered out (never null)
headers
,
URI
the target URI for the handshake (never null)
uri
,
List<String>
requested sub-protocols, or an empty list
subProtocols
,
List<WebSocketExtension>
requested WebSocket extensions, or an empty list
extensions
,
Map<String, Object>
the attributes to associate with the WebSocketSession, i.e. via WebSocketSession#getAttributes(); currently always an empty map
attributes
)

Perform the actual handshake to establish a connection to the server.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

loggerback to summary
protected final Log logger
specialHeadersback to summary
private static final Set<String> specialHeaders

Constructor Detail

AbstractWebSocketClientback to summary
public AbstractWebSocketClient()

Method Detail

assertUriback to summary
protected void assertUri(URI uri)
doHandshakeInternalback to summary
protected ListenableFuture<WebSocketSession> doHandshakeInternal(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:WebSocketHandler

the client-side handler for WebSocket messages

headers:HttpHeaders

the HTTP headers to use for the handshake, with unwanted (forbidden) headers filtered out (never null)

uri:URI

the target URI for the handshake (never null)

subProtocols:List<String>

requested sub-protocols, or an empty list

extensions:List<WebSocketExtension>

requested WebSocket extensions, or an empty list

attributes:Map<String, Object>

the attributes to associate with the WebSocketSession, i.e. via WebSocketSession#getAttributes(); currently always an empty map.

Returns:ListenableFuture<WebSocketSession>

the established WebSocket session wrapped in a ListenableFuture.

Annotations
@Deprecated
since:6.0
executeback to summary
public CompletableFuture<WebSocketSession> execute(WebSocketHandler webSocketHandler, String uriTemplate, Object... uriVars)

Implements org.springframework.web.socket.client.WebSocketClient.execute.

Doc from org.springframework.web.socket.client.WebSocketClient.execute.

Execute a handshake request to the given url and handle the resulting WebSocket session with the given handler.

Parameters
webSocketHandler:WebSocketHandler

the session handler

uriTemplate:String

the url template

uriVars:Object[]

the variables to expand the template

Returns:CompletableFuture<WebSocketSession>

a future that completes when the session is available

Annotations
@Override
executeback to summary
public final CompletableFuture<WebSocketSession> execute(WebSocketHandler webSocketHandler, WebSocketHttpHeaders headers, URI uri)

Implements org.springframework.web.socket.client.WebSocketClient.execute.

Doc from org.springframework.web.socket.client.WebSocketClient.execute.

Execute a handshake request to the given url and handle the resulting WebSocket session with the given handler.

Parameters
webSocketHandler:WebSocketHandler

the session handler

uri:URI

the url

Returns:CompletableFuture<WebSocketSession>

a future that completes when the session is available

Annotations
@Override
executeInternalback to summary
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:WebSocketHandler

the client-side handler for WebSocket messages

headers:HttpHeaders

the HTTP headers to use for the handshake, with unwanted (forbidden) headers filtered out (never null)

uri:URI

the target URI for the handshake (never null)

subProtocols:List<String>

requested sub-protocols, or an empty list

extensions:List<WebSocketExtension>

requested WebSocket extensions, or an empty list

attributes:Map<String, Object>

the attributes to associate with the WebSocketSession, i.e. via WebSocketSession#getAttributes(); currently always an empty map

Returns:CompletableFuture<WebSocketSession>

the established WebSocket session wrapped in a CompletableFuture.