org.springframework.web.socket.sockjs.SockJsService
with support for SPI-based transport handling and session management.
Based on the TransportHandler SPI. TransportHandlers may
additionally implement the SockJsSessionFactory and HandshakeHandler interfaces.
See the AbstractSockJsService base class for important details on request mapping.
| Modifier and Type | Field and Description |
|---|---|
| private final Map | |
| private final List | |
| private static final boolean | |
| private SockJsMessageCodec | |
| private volatile boolean | |
| private ScheduledFuture | |
| private final Map |
| Access | Constructor and Description |
|---|---|
| public | TransportHandlingSockJsService(TaskScheduler
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 stops scheduler, TransportHandler... one or more handlers)TransportHandler implementations to useCreate a TransportHandlingSockJsService with given |
| public | TransportHandlingSockJsService(TaskScheduler
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 stops scheduler, Collection<TransportHandler> one or more handlers)TransportHandler implementations to useCreate a TransportHandlingSockJsService with given |
| Modifier and Type | Method and Description |
|---|---|
| private SockJsSession | createSockJsSession(String sessionId, SockJsSessionFactory sessionFactory, WebSocketHandler handler, Map<String, Object> attributes)
|
| public List | |
| public SockJsMessageCodec | getMessageCodec()
Implements org. The codec to use for encoding and decoding SockJS messages. |
| public Map | |
| protected void | handleRawWebSocketRequest(ServerHttpRequest request, ServerHttpResponse response, WebSocketHandler handler)
Implements abstract org. Handle request for raw WebSocket communication, i.e. without any SockJS message framing. |
| protected void | handleTransportRequest(ServerHttpRequest request, ServerHttpResponse response, WebSocketHandler handler, String sessionId, String transport)
Implements abstract org. Handle a SockJS session URL (i.e. transport-specific request). |
| public boolean | isRunning()
Implements org. Check whether this component is currently running. |
| private void | |
| public void | setHandshakeInterceptors(List<HandshakeInterceptor> interceptors)
Configure one or more WebSocket handshake request interceptors. |
| public void | setMessageCodec(SockJsMessageCodec messageCodec)
The codec to use for encoding and decoding SockJS messages. |
| public void | |
| public void | stop()
Implements org. Stop this component, typically in a synchronous fashion, such that the component is fully stopped upon return of this method. |
| protected boolean | validateRequest(String serverId, String sessionId, String transport)
Overrides org.
|
| handlers | back to summary |
|---|---|
| private final Map<TransportType, TransportHandler> handlers | |
| interceptors | back to summary |
|---|---|
| private final List<HandshakeInterceptor> interceptors | |
| jackson2Present | back to summary |
|---|---|
| private static final boolean jackson2Present | |
| messageCodec | back to summary |
|---|---|
| private SockJsMessageCodec messageCodec
| |
| running | back to summary |
|---|---|
| private volatile boolean running | |
| sessionCleanupTask | back to summary |
|---|---|
| private ScheduledFuture<?> sessionCleanupTask
| |
| sessions | back to summary |
|---|---|
| private final Map<String, SockJsSession> sessions | |
| TransportHandlingSockJsService | back to summary |
|---|---|
| public TransportHandlingSockJsService(TaskScheduler scheduler, TransportHandler... handlers) Create a TransportHandlingSockJsService with given
| |
| TransportHandlingSockJsService | back to summary |
|---|---|
| public TransportHandlingSockJsService(TaskScheduler scheduler, Collection<TransportHandler> handlers) Create a TransportHandlingSockJsService with given
| |
| createSockJsSession | back to summary |
|---|---|
| private SockJsSession createSockJsSession(String sessionId, SockJsSessionFactory sessionFactory, WebSocketHandler handler, Map<String, Object> attributes) | |
| getHandshakeInterceptors | back to summary |
|---|---|
| public List Return the configured WebSocket handshake request interceptors. | |
| getMessageCodec | back to summary |
|---|---|
| public SockJsMessageCodec getMessageCodec() Implements org. Doc from org. The codec to use for encoding and decoding SockJS messages.
| |
| getTransportHandlers | back to summary |
|---|---|
| public Map Return the registered handlers per transport type. | |
| handleRawWebSocketRequest | back to summary |
|---|---|
| protected void handleRawWebSocketRequest(ServerHttpRequest request, ServerHttpResponse response, WebSocketHandler handler) throws IOException Implements abstract org. Doc from org. Handle request for raw WebSocket communication, i.e. without any SockJS message framing.
| |
| handleTransportRequest | back to summary |
|---|---|
| protected void handleTransportRequest(ServerHttpRequest request, ServerHttpResponse response, WebSocketHandler handler, String sessionId, String transport) throws SockJsException Implements abstract org. Doc from org. Handle a SockJS session URL (i.e. transport-specific request).
| |
| isRunning | back to summary |
|---|---|
| public boolean isRunning() Implements org. Doc from org. Check whether this component is currently running. In the case of a container, this will return
| |
| scheduleSessionTask | back to summary |
|---|---|
| private void scheduleSessionTask() | |
| setHandshakeInterceptors | back to summary |
|---|---|
| public void setHandshakeInterceptors(List<HandshakeInterceptor> interceptors) Configure one or more WebSocket handshake request interceptors. | |
| setMessageCodec | back to summary |
|---|---|
| public void setMessageCodec(SockJsMessageCodec messageCodec) The codec to use for encoding and decoding SockJS messages. | |
| start | back to summary |
|---|---|
| public void start() Implements org. Doc from org. Start this component. Should not throw an exception if the component is already running. In the case of a container, this will propagate the start signal to all components that apply.
| |
| stop | back to summary |
|---|---|
| public void stop() Implements org. Doc from org. Stop this component, typically in a synchronous fashion, such that the component is
fully stopped upon return of this method. Consider implementing Note that this stop notification is not guaranteed to come before destruction:
On regular shutdown, Should not throw an exception if the component is not running (not started yet). In the case of a container, this will propagate the stop signal to all components that apply.
| |
| validateRequest | back to summary |
|---|---|
| protected boolean validateRequest(String serverId, String sessionId, String transport) Overrides org.
| |