public class JettyWebSocketClient extends AbstractWebSocketClient implements org.springframework.context.SmartLifecycle
logger
Constructor and Description |
---|
JettyWebSocketClient()
Default constructor that creates an instance of
WebSocketClient with default settings. |
JettyWebSocketClient(org.eclipse.jetty.websocket.client.WebSocketClient client)
Constructor that accepts a pre-configured
WebSocketClient . |
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> handshakeAttributes)
Perform the actual handshake to establish a connection to the server.
|
int |
getPhase() |
org.springframework.core.task.AsyncListenableTaskExecutor |
getTaskExecutor()
Return the configured
TaskExecutor . |
protected Principal |
getUser() |
boolean |
isAutoStartup() |
boolean |
isRunning() |
void |
setAutoStartup(boolean autoStartup) |
void |
setPhase(int phase) |
void |
setTaskExecutor(org.springframework.core.task.AsyncListenableTaskExecutor taskExecutor)
Set a
TaskExecutor to use to open the connection. |
void |
start() |
void |
stop() |
void |
stop(Runnable callback) |
doHandshake
public JettyWebSocketClient()
WebSocketClient
with default settings.public JettyWebSocketClient(org.eclipse.jetty.websocket.client.WebSocketClient client)
WebSocketClient
.public void setTaskExecutor(org.springframework.core.task.AsyncListenableTaskExecutor taskExecutor)
TaskExecutor
to use to open the connection.
By default SimpleAsyncTaskExecutor
is used.public org.springframework.core.task.AsyncListenableTaskExecutor getTaskExecutor()
TaskExecutor
.public void setAutoStartup(boolean autoStartup)
public boolean isAutoStartup()
isAutoStartup
in interface org.springframework.context.SmartLifecycle
public void setPhase(int phase)
public int getPhase()
getPhase
in interface org.springframework.context.Phased
public boolean isRunning()
isRunning
in interface org.springframework.context.Lifecycle
public void start()
start
in interface org.springframework.context.Lifecycle
public void stop()
stop
in interface org.springframework.context.Lifecycle
public void stop(Runnable callback)
stop
in interface org.springframework.context.SmartLifecycle
public org.springframework.util.concurrent.ListenableFuture<WebSocketSession> doHandshake(WebSocketHandler webSocketHandler, String uriTemplate, Object... uriVars)
doHandshake
in interface WebSocketClient
doHandshake
in class AbstractWebSocketClient
public 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> handshakeAttributes)
AbstractWebSocketClient
doHandshakeInternal
in class AbstractWebSocketClient
wsHandler
- the client-side handler for WebSocket messagesheaders
- 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 listhandshakeAttributes
- attributes to make available via
WebSocketSession.getHandshakeAttributes()
; currently always an empty map.protected Principal getUser()
WebSocketSession.getPrincipal()
;
by default this method returns null