类 TransportHandlingSockJsService
- java.lang.Object
- org.springframework.web.socket.sockjs.support.AbstractSockJsService
- org.springframework.web.socket.sockjs.transport.TransportHandlingSockJsService
- 直接已知子类:
DefaultSockJsService
public class TransportHandlingSockJsService extends AbstractSockJsService implements SockJsServiceConfig, Lifecycle
A basic implementation ofSockJsService
with support for SPI-based transport handling and session management.Based on the
TransportHandler
SPI.TransportHandler
s may additionally implement theSockJsSessionFactory
andHandshakeHandler
interfaces.See the
AbstractSockJsService
base class for important details on request mapping.- 从以下版本开始:
- 4.0
- 作者:
- Rossen Stoyanchev, Juergen Hoeller, Sebastien Deleuze
字段概要
从类继承的字段 org.springframework.web.socket.sockjs.support.AbstractSockJsService
allowedOrigins, logger
构造器概要
构造器 构造器 说明 TransportHandlingSockJsService(TaskScheduler scheduler, Collection<TransportHandler> handlers)
Create a TransportHandlingSockJsService with givenhandler
types.TransportHandlingSockJsService(TaskScheduler scheduler, TransportHandler... handlers)
Create a TransportHandlingSockJsService with givenhandler
types.
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 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(ServerHttpRequest request, ServerHttpResponse response, WebSocketHandler handler)
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)
Handle a SockJS session URL (i.e. transport-specific request).boolean
isRunning()
Check whether this component is currently running.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()
Start this component.void
stop()
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)
从类继承的方法 org.springframework.web.socket.sockjs.support.AbstractSockJsService
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
从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
从接口继承的方法 org.springframework.web.socket.sockjs.transport.SockJsServiceConfig
getHeartbeatTime, getHttpMessageCacheSize, getStreamBytesLimit, getTaskScheduler
构造器详细资料
TransportHandlingSockJsService
public TransportHandlingSockJsService(TaskScheduler scheduler, TransportHandler... handlers)
Create a TransportHandlingSockJsService with givenhandler
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 moreTransportHandler
implementations to use
TransportHandlingSockJsService
public TransportHandlingSockJsService(TaskScheduler scheduler, Collection<TransportHandler> handlers)
Create a TransportHandlingSockJsService with givenhandler
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 moreTransportHandler
implementations to use
方法详细资料
getTransportHandlers
public Map<TransportType,TransportHandler> getTransportHandlers()
Return the registered handlers per transport type.
setMessageCodec
public void setMessageCodec(SockJsMessageCodec messageCodec)
The codec to use for encoding and decoding SockJS messages.
getMessageCodec
public SockJsMessageCodec getMessageCodec()
从接口复制的说明:SockJsServiceConfig
The codec to use for encoding and decoding SockJS messages.- 指定者:
getMessageCodec
在接口中SockJsServiceConfig
setHandshakeInterceptors
public void setHandshakeInterceptors(List<HandshakeInterceptor> interceptors)
Configure one or more WebSocket handshake request interceptors.
getHandshakeInterceptors
public List<HandshakeInterceptor> getHandshakeInterceptors()
Return the configured WebSocket handshake request interceptors.
start
public void start()
从接口复制的说明:Lifecycle
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.
- 指定者:
start
在接口中Lifecycle
- 另请参阅:
SmartLifecycle.isAutoStartup()
stop
public void stop()
从接口复制的说明:Lifecycle
Stop this component, typically in a synchronous fashion, such that the component is fully stopped upon return of this method. Consider implementingSmartLifecycle
and itsstop(Runnable)
variant when asynchronous stop behavior is necessary.Note that this stop notification is not guaranteed to come before destruction: On regular shutdown,
Lifecycle
beans will first receive a stop notification before the general destruction callbacks are being propagated; however, on hot refresh during a context's lifetime or on aborted refresh attempts, a given bean's destroy method will be called without any consideration of stop signals upfront.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.
- 指定者:
stop
在接口中Lifecycle
- 另请参阅:
SmartLifecycle.stop(Runnable)
,DisposableBean.destroy()
isRunning
public boolean isRunning()
从接口复制的说明:Lifecycle
Check whether this component is currently running.In the case of a container, this will return
true
only if all components that apply are currently running.
handleRawWebSocketRequest
protected void handleRawWebSocketRequest(ServerHttpRequest request, ServerHttpResponse response, WebSocketHandler handler) throws IOException
从类复制的说明:AbstractSockJsService
Handle request for raw WebSocket communication, i.e. without any SockJS message framing.
handleTransportRequest
protected void handleTransportRequest(ServerHttpRequest request, ServerHttpResponse response, WebSocketHandler handler, String sessionId, String transport) throws SockJsException
从类复制的说明:AbstractSockJsService
Handle a SockJS session URL (i.e. transport-specific request).
validateRequest
protected boolean validateRequest(String serverId, String sessionId, String transport)