public class DefaultHandshakeHandler extends java.lang.Object implements HandshakeHandler
HandshakeHandler.
A container-specific RequestUpgradeStrategy is required since standard Java
WebSocket currently does not provide a way to initiate a WebSocket handshake.
Currently available are implementations for Tomcat and GlassFish.
| Constructor and Description |
|---|
DefaultHandshakeHandler()
Default constructor that auto-detects and instantiates a
RequestUpgradeStrategy suitable for the runtime container. |
DefaultHandshakeHandler(RequestUpgradeStrategy upgradeStrategy)
A constructor that accepts a runtime specific
RequestUpgradeStrategy. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
doHandshake(ServerHttpRequest request,
ServerHttpResponse response,
WebSocketHandler webSocketHandler)
Initiate the handshake.
|
java.lang.String[] |
getSupportedProtocols() |
protected java.lang.String[] |
getSupportedVerions() |
protected void |
handleInvalidConnectHeader(ServerHttpRequest request,
ServerHttpResponse response) |
protected void |
handleInvalidUpgradeHeader(ServerHttpRequest request,
ServerHttpResponse response) |
protected void |
handleWebSocketVersionNotSupported(ServerHttpRequest request,
ServerHttpResponse response) |
protected boolean |
isValidOrigin(ServerHttpRequest request) |
protected boolean |
isWebSocketVersionSupported(ServerHttpRequest request) |
protected java.lang.String |
selectProtocol(java.util.List<java.lang.String> requestedProtocols) |
void |
setSupportedProtocols(java.lang.String... protocols) |
protected Log logger
public DefaultHandshakeHandler()
RequestUpgradeStrategy suitable for the runtime container.java.lang.IllegalStateException - if no RequestUpgradeStrategy can be found.public DefaultHandshakeHandler(RequestUpgradeStrategy upgradeStrategy)
RequestUpgradeStrategy.upgradeStrategy - the upgrade strategypublic void setSupportedProtocols(java.lang.String... protocols)
public java.lang.String[] getSupportedProtocols()
public final boolean doHandshake(ServerHttpRequest request, ServerHttpResponse response, WebSocketHandler webSocketHandler) throws java.io.IOException, HandshakeFailureException
HandshakeHandlerdoHandshake in interface HandshakeHandlerrequest - the current requestresponse - the current responsewebSocketHandler - the handler to process WebSocket messages; see
PerConnectionWebSocketHandler for providing a handler with
per-connection lifecycle.java.io.IOException - thrown when accessing or setting the responseHandshakeFailureException - thrown when handshake processing failed to
complete due to an internal, unrecoverable error, i.e. a server error as
opposed to a failure to successfully negotiate the requirements of the
handshake request.protected void handleInvalidUpgradeHeader(ServerHttpRequest request, ServerHttpResponse response) throws java.io.IOException
java.io.IOExceptionprotected void handleInvalidConnectHeader(ServerHttpRequest request, ServerHttpResponse response) throws java.io.IOException
java.io.IOExceptionprotected boolean isWebSocketVersionSupported(ServerHttpRequest request)
protected java.lang.String[] getSupportedVerions()
protected void handleWebSocketVersionNotSupported(ServerHttpRequest request, ServerHttpResponse response)
protected boolean isValidOrigin(ServerHttpRequest request)
protected java.lang.String selectProtocol(java.util.List<java.lang.String> requestedProtocols)