public class TransportHandlingSockJsService extends AbstractSockJsService implements SockJsServiceConfig, org.springframework.context.Lifecycle
SockJsService
with support for SPI-based transport handling and session management.
Based on the TransportHandler
SPI. TransportHandler
s may additionally
implement the SockJsSessionFactory
and HandshakeHandler
interfaces.
See the AbstractSockJsService
base class for important details on request mapping.
allowedOrigins, logger
Constructor and Description |
---|
TransportHandlingSockJsService(org.springframework.scheduling.TaskScheduler scheduler,
Collection<TransportHandler> handlers)
Create a TransportHandlingSockJsService with given
handler types. |
TransportHandlingSockJsService(org.springframework.scheduling.TaskScheduler scheduler,
TransportHandler... handlers)
Create a TransportHandlingSockJsService with given
handler types. |
Modifier and Type | Method and Description |
---|---|
List<HandshakeInterceptor> |
getHandshakeInterceptors()
Return the configured WebSocket handshake request interceptors.
|
SockJsMessageCodec |
getMessageCodec()
The codec to use for encoding and decoding SockJS messages.
|
Map<TransportType,TransportHandler> |
getTransportHandlers()
Return the registered handlers per transport type.
|
protected void |
handleRawWebSocketRequest(org.springframework.http.server.ServerHttpRequest request,
org.springframework.http.server.ServerHttpResponse response,
WebSocketHandler handler)
Handle request for raw WebSocket communication, i.e.
|
protected void |
handleTransportRequest(org.springframework.http.server.ServerHttpRequest request,
org.springframework.http.server.ServerHttpResponse response,
WebSocketHandler handler,
String sessionId,
String transport)
Handle a SockJS session URL (i.e.
|
boolean |
isRunning() |
void |
setHandshakeInterceptors(List<HandshakeInterceptor> interceptors)
Configure one or more WebSocket handshake request interceptors.
|
void |
setMessageCodec(SockJsMessageCodec messageCodec)
The codec to use for encoding and decoding SockJS messages.
|
void |
start() |
void |
stop() |
protected boolean |
validateRequest(String serverId,
String sessionId,
String transport) |
addCacheHeaders, addNoCacheHeaders, checkOrigin, getAllowedOrigins, getCorsConfiguration, getDisconnectDelay, getHeartbeatTime, getHttpMessageCacheSize, getName, getSockJsClientLibraryUrl, getStreamBytesLimit, getTaskScheduler, handleRequest, isSessionCookieNeeded, isWebSocketEnabled, sendMethodNotAllowed, setAllowedOrigins, setDisconnectDelay, setHeartbeatTime, setHttpMessageCacheSize, setName, setSessionCookieNeeded, setSockJsClientLibraryUrl, setStreamBytesLimit, setSuppressCors, setWebSocketEnabled, shouldSuppressCors
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getHeartbeatTime, getHttpMessageCacheSize, getStreamBytesLimit, getTaskScheduler
public TransportHandlingSockJsService(org.springframework.scheduling.TaskScheduler scheduler, TransportHandler... handlers)
handler
types.scheduler
- a task scheduler for heart-beat messages and removing timed-out sessions;
the provided TaskScheduler should be declared as a Spring bean to ensure it gets
initialized at start-up and shuts down when the application stopshandlers
- one or more TransportHandler
implementations to usepublic TransportHandlingSockJsService(org.springframework.scheduling.TaskScheduler scheduler, Collection<TransportHandler> handlers)
handler
types.scheduler
- a task scheduler for heart-beat messages and removing timed-out sessions;
the provided TaskScheduler should be declared as a Spring bean to ensure it gets
initialized at start-up and shuts down when the application stopshandlers
- one or more TransportHandler
implementations to usepublic Map<TransportType,TransportHandler> getTransportHandlers()
public void setMessageCodec(SockJsMessageCodec messageCodec)
public SockJsMessageCodec getMessageCodec()
SockJsServiceConfig
getMessageCodec
in interface SockJsServiceConfig
public void setHandshakeInterceptors(List<HandshakeInterceptor> interceptors)
public List<HandshakeInterceptor> getHandshakeInterceptors()
public void start()
start
in interface org.springframework.context.Lifecycle
public void stop()
stop
in interface org.springframework.context.Lifecycle
public boolean isRunning()
isRunning
in interface org.springframework.context.Lifecycle
protected void handleRawWebSocketRequest(org.springframework.http.server.ServerHttpRequest request, org.springframework.http.server.ServerHttpResponse response, WebSocketHandler handler) throws IOException
AbstractSockJsService
handleRawWebSocketRequest
in class AbstractSockJsService
IOException
protected void handleTransportRequest(org.springframework.http.server.ServerHttpRequest request, org.springframework.http.server.ServerHttpResponse response, WebSocketHandler handler, String sessionId, String transport) throws SockJsException
AbstractSockJsService
handleTransportRequest
in class AbstractSockJsService
SockJsException
protected boolean validateRequest(String serverId, String sessionId, String transport)
validateRequest
in class AbstractSockJsService