public class JettyWebSocketClient extends AbstractWebSocketClient implements org.springframework.context.Lifecycle
As of 4.1 this class implements Lifecycle rather than
SmartLifecycle. Use
WebSocketConnectionManager instead to auto-start a WebSocket connection.
logger| Constructor and Description |
|---|
JettyWebSocketClient()
Default constructor that creates an instance of
WebSocketClient. |
JettyWebSocketClient(org.eclipse.jetty.websocket.client.WebSocketClient client)
Constructor that accepts an existing
WebSocketClient instance. |
| Modifier and Type | Method and Description |
|---|---|
org.springframework.util.concurrent.ListenableFuture<WebSocketSession> |
doHandshake(WebSocketHandler webSocketHandler,
String uriTemplate,
Object... uriVars) |
org.springframework.util.concurrent.ListenableFuture<WebSocketSession> |
doHandshakeInternal(WebSocketHandler wsHandler,
org.springframework.http.HttpHeaders headers,
URI uri,
List<String> protocols,
List<WebSocketExtension> extensions,
Map<String,Object> attributes)
Perform the actual handshake to establish a connection to the server.
|
org.springframework.core.task.AsyncListenableTaskExecutor |
getTaskExecutor()
Return the configured
TaskExecutor. |
protected Principal |
getUser()
Return the user to make available through
WebSocketSession.getPrincipal(). |
boolean |
isRunning() |
void |
setTaskExecutor(org.springframework.core.task.AsyncListenableTaskExecutor taskExecutor)
Set an
AsyncListenableTaskExecutor to use when opening connections. |
void |
start() |
void |
stop() |
assertUri, doHandshakepublic JettyWebSocketClient()
WebSocketClient.public JettyWebSocketClient(org.eclipse.jetty.websocket.client.WebSocketClient client)
WebSocketClient instance.public void setTaskExecutor(@Nullable
org.springframework.core.task.AsyncListenableTaskExecutor taskExecutor)
AsyncListenableTaskExecutor to use when opening connections.
If this property is set to null, calls to any of the
doHandshake methods will block until the connection is established.
By default an instance of SimpleAsyncTaskExecutor is used.
@Nullable public org.springframework.core.task.AsyncListenableTaskExecutor getTaskExecutor()
TaskExecutor.public void start()
start in interface org.springframework.context.Lifecyclepublic void stop()
stop in interface org.springframework.context.Lifecyclepublic boolean isRunning()
isRunning in interface org.springframework.context.Lifecyclepublic org.springframework.util.concurrent.ListenableFuture<WebSocketSession> doHandshake(WebSocketHandler webSocketHandler, String uriTemplate, Object... uriVars)
doHandshake in interface WebSocketClientdoHandshake in class AbstractWebSocketClientpublic org.springframework.util.concurrent.ListenableFuture<WebSocketSession> doHandshakeInternal(WebSocketHandler wsHandler, org.springframework.http.HttpHeaders headers, URI uri, List<String> protocols, List<WebSocketExtension> extensions, Map<String,Object> attributes)
AbstractWebSocketClientdoHandshakeInternal in class AbstractWebSocketClientwsHandler - the client-side handler for WebSocket messagesheaders - the HTTP headers to use for the handshake, with unwanted (forbidden)
headers filtered out (never null)uri - the target URI for the handshake (never null)protocols - requested sub-protocols, or an empty listextensions - requested WebSocket extensions, or an empty listattributes - the attributes to associate with the WebSocketSession, i.e. via
WebSocketSession.getAttributes(); currently always an empty map.@Nullable protected Principal getUser()
WebSocketSession.getPrincipal().
By default this method returns null