public class WebSocketConnectionManager extends ConnectionManagerSupport
connection manager
that connects
to the server via WebSocketClient
and handles the session with a
WebSocketHandler
.logger
DEFAULT_PHASE
Constructor and Description |
---|
WebSocketConnectionManager(WebSocketClient client,
WebSocketHandler webSocketHandler,
String uriTemplate,
Object... uriVariables) |
Modifier and Type | Method and Description |
---|---|
protected void |
closeConnection()
Subclasses implement this to close the connection.
|
protected WebSocketHandler |
decorateWebSocketHandler(WebSocketHandler handler)
Decorate the WebSocketHandler provided to the class constructor.
|
HttpHeaders |
getHeaders()
Return the default headers for the WebSocket handshake request.
|
String |
getOrigin()
Return the configured origin.
|
List<String> |
getSubProtocols()
Return the configured sub-protocols to use.
|
boolean |
isConnected()
Whether the connection is open/
true or closed/false . |
protected void |
openConnection()
Subclasses implement this to actually establish the connection.
|
void |
setHeaders(HttpHeaders headers)
Provide default headers to add to the WebSocket handshake request.
|
void |
setOrigin(String origin)
Set the origin to use.
|
void |
setSubProtocols(List<String> protocols)
Set the sub-protocols to use.
|
void |
startInternal() |
void |
stopInternal() |
getPhase, getUri, isAutoStartup, isRunning, setAutoStartup, setPhase, start, stop, stop
public WebSocketConnectionManager(WebSocketClient client, WebSocketHandler webSocketHandler, String uriTemplate, Object... uriVariables)
public void setSubProtocols(List<String> protocols)
Sec-WebSocket-Protocol
header. The
resulting WebSocket session will contain the protocol accepted by the server, if
any.public void setHeaders(HttpHeaders headers)
public HttpHeaders getHeaders()
public void startInternal()
startInternal
in class ConnectionManagerSupport
public void stopInternal() throws Exception
stopInternal
in class ConnectionManagerSupport
Exception
public boolean isConnected()
ConnectionManagerSupport
true
or closed/false
.isConnected
in class ConnectionManagerSupport
protected void openConnection()
ConnectionManagerSupport
openConnection
in class ConnectionManagerSupport
protected void closeConnection() throws Exception
ConnectionManagerSupport
closeConnection
in class ConnectionManagerSupport
Exception
protected WebSocketHandler decorateWebSocketHandler(WebSocketHandler handler)
By default LoggingWebSocketHandlerDecorator
is added.