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, setSockJsServiceConfiguration
public WebSocketTransportHandler(HandshakeHandler handshakeHandler)
public TransportType getTransportType()
getTransportType
in interface TransportHandler
public HandshakeHandler getHandshakeHandler()
public AbstractSockJsSession createSession(String sessionId, WebSocketHandler wsHandler, Map<String,Object> attributes)
SockJsSessionFactory
createSession
in interface SockJsSessionFactory
sessionId
- the ID of the sessionwsHandler
- the underlying WebSocketHandler
attributes
- handshake request specific attributesnull
public void handleRequest(ServerHttpRequest request, ServerHttpResponse response, WebSocketHandler wsHandler, WebSocketSession wsSession) throws SockJsException
TransportHandler
WebSocketHandler
.handleRequest
in interface TransportHandler
request
- the current requestresponse
- the current responsewsHandler
- the target WebSocketHandler, never null
wsSession
- the SockJS session, never null
SockJsException
- raised when request processing fails as explained in
SockJsService
public boolean doHandshake(ServerHttpRequest request, ServerHttpResponse response, WebSocketHandler handler, Map<String,Object> attributes) throws HandshakeFailureException
HandshakeHandler
doHandshake
in interface HandshakeHandler
request
- 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.