public class WebSocketTransportHandler extends AbstractTransportHandler implements SockJsSessionFactory, HandshakeHandler
TransportHandler. Uses SockJsWebSocketHandler and
WebSocketServerSockJsSession to add SockJS processing.
Also implements HandshakeHandler to support raw WebSocket communication at
SockJS URL "/websocket".
logger, UTF8_CHARSET| Constructor and Description |
|---|
WebSocketTransportHandler(HandshakeHandler handshakeHandler) |
| Modifier and Type | Method and Description |
|---|---|
AbstractSockJsSession |
createSession(String sessionId,
WebSocketHandler handler,
Map<String,Object> attributes)
Create a new SockJS session.
|
boolean |
doHandshake(org.springframework.http.server.ServerHttpRequest request,
org.springframework.http.server.ServerHttpResponse response,
WebSocketHandler handler,
Map<String,Object> attributes)
Initiate the handshake.
|
HandshakeHandler |
getHandshakeHandler() |
TransportType |
getTransportType()
Return the transport type supported by this handler.
|
void |
handleRequest(org.springframework.http.server.ServerHttpRequest request,
org.springframework.http.server.ServerHttpResponse response,
WebSocketHandler wsHandler,
SockJsSession wsSession)
Handle the given request and delegate messages to the provided
WebSocketHandler. |
getServiceConfig, initializepublic WebSocketTransportHandler(HandshakeHandler handshakeHandler)
public TransportType getTransportType()
TransportHandlergetTransportType in interface TransportHandlerpublic HandshakeHandler getHandshakeHandler()
public AbstractSockJsSession createSession(String sessionId, WebSocketHandler handler, Map<String,Object> attributes)
SockJsSessionFactorycreateSession in interface SockJsSessionFactorysessionId - the ID of the sessionhandler - the underlying WebSocketHandlerattributes - handshake request specific attributesnullpublic void handleRequest(org.springframework.http.server.ServerHttpRequest request,
org.springframework.http.server.ServerHttpResponse response,
WebSocketHandler wsHandler,
SockJsSession wsSession)
throws SockJsException
TransportHandlerWebSocketHandler.handleRequest in interface TransportHandlerrequest - 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 SockJsServicepublic boolean doHandshake(org.springframework.http.server.ServerHttpRequest request,
org.springframework.http.server.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 - attributes from the HTTP handshake to associate with the WebSocket
session; the provided attributes are copied, the original map is not used.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.