public class WebSocketTransportHandler extends TransportHandlerSupport implements TransportHandler, SockJsSessionFactory, HandshakeHandler
TransportHandler. Uses SockJsWebSocketHandler and
WebSocketServerSockJsSession to add SockJS processing.
Also implements HandshakeHandler to support raw WebSocket communication at
SockJS URL "/websocket".
logger| Constructor and Description |
|---|
WebSocketTransportHandler(HandshakeHandler handshakeHandler) |
| Modifier and Type | Method and Description |
|---|---|
AbstractSockJsSession |
createSession(String sessionId,
WebSocketHandler wsHandler,
Map<String,Object> attributes)
Create a new SockJS session.
|
boolean |
doHandshake(ServerHttpRequest request,
ServerHttpResponse response,
WebSocketHandler handler,
Map<String,Object> attributes)
Initiate the handshake.
|
HandshakeHandler |
getHandshakeHandler() |
TransportType |
getTransportType() |
void |
handleRequest(ServerHttpRequest request,
ServerHttpResponse response,
WebSocketHandler wsHandler,
WebSocketSession wsSession)
Handle the given request and delegate messages to the provided
WebSocketHandler. |
getSockJsServiceConfig, setSockJsServiceConfigurationpublic WebSocketTransportHandler(HandshakeHandler handshakeHandler)
public TransportType getTransportType()
getTransportType in interface TransportHandlerpublic HandshakeHandler getHandshakeHandler()
public AbstractSockJsSession createSession(String sessionId, WebSocketHandler wsHandler, Map<String,Object> attributes)
SockJsSessionFactorycreateSession in interface SockJsSessionFactorysessionId - the ID of the sessionwsHandler - the underlying WebSocketHandlerattributes - handshake request specific attributesnullpublic void handleRequest(ServerHttpRequest request, ServerHttpResponse response, WebSocketHandler wsHandler, WebSocketSession wsSession) throws SockJsException
TransportHandlerWebSocketHandler.handleRequest in interface TransportHandlerrequest - the current requestresponse - the current responsewsHandler - the target WebSocketHandler, never nullwsSession - the SockJS session, never nullSockJsException - raised when request processing fails as explained in
SockJsServicepublic boolean doHandshake(ServerHttpRequest request, ServerHttpResponse response, WebSocketHandler handler, Map<String,Object> attributes) throws HandshakeFailureException
HandshakeHandlerdoHandshake in interface HandshakeHandlerrequest - the current requestresponse - the current responsehandler - the handler to process WebSocket messages; see
PerConnectionWebSocketHandler for providing a handler with
per-connection lifecycle.attributes - handshake request specific attributes to be set on the WebSocket
session via HandshakeInterceptor and thus made available to the
WebSocketHandler;HandshakeFailureException - 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 handshake.