public class SockJsServiceRegistration extends Object
EnableWebSocket
and
WebSocketConfigurer
setup.Constructor and Description |
---|
SockJsServiceRegistration() |
Modifier and Type | Method and Description |
---|---|
protected SockJsService |
getSockJsService() |
protected TaskScheduler |
getTaskScheduler()
Return the TaskScheduler, if configured.
|
protected SockJsServiceRegistration |
setAllowedOriginPatterns(String... allowedOriginPatterns)
Configure allowed
Origin pattern header values. |
protected SockJsServiceRegistration |
setAllowedOrigins(String... allowedOrigins)
Configure allowed
Origin header values. |
SockJsServiceRegistration |
setClientLibraryUrl(String clientLibraryUrl)
Transports with no native cross-domain communication (e.g.
|
SockJsServiceRegistration |
setDisconnectDelay(long disconnectDelay)
The amount of time in milliseconds before a client is considered
disconnected after not having a receiving connection, i.e.
|
SockJsServiceRegistration |
setHeartbeatTime(long heartbeatTime)
The amount of time in milliseconds when the server has not sent any
messages and after which the server should send a heartbeat frame to the
client in order to keep the connection from breaking.
|
SockJsServiceRegistration |
setHttpMessageCacheSize(int httpMessageCacheSize)
The number of server-to-client messages that a session can cache while waiting for
the next HTTP polling request from the client.
|
SockJsServiceRegistration |
setInterceptors(HandshakeInterceptor... interceptors) |
SockJsServiceRegistration |
setMessageCodec(SockJsMessageCodec codec)
The codec to use for encoding and decoding SockJS messages.
|
SockJsServiceRegistration |
setSessionCookieNeeded(boolean sessionCookieNeeded)
The SockJS protocol requires a server to respond to the initial "/info" request
from clients with a "cookie_needed" boolean property that indicates whether the use
of a JSESSIONID cookie is required for the application to function correctly, e.g.
|
SockJsServiceRegistration |
setStreamBytesLimit(int streamBytesLimit)
Streaming transports save responses on the client side and don't free
memory used by delivered messages.
|
SockJsServiceRegistration |
setSupressCors(boolean suppressCors)
This option can be used to disable automatic addition of CORS headers for
SockJS requests.
|
SockJsServiceRegistration |
setTaskScheduler(TaskScheduler scheduler)
A scheduler instance to use for scheduling SockJS heart-beats.
|
SockJsServiceRegistration |
setTransportHandlerOverrides(TransportHandler... handlers) |
SockJsServiceRegistration |
setTransportHandlers(TransportHandler... handlers) |
SockJsServiceRegistration |
setWebSocketEnabled(boolean webSocketEnabled)
Some load balancers don't support WebSocket.
|
public SockJsServiceRegistration setTaskScheduler(TaskScheduler scheduler)
public SockJsServiceRegistration setClientLibraryUrl(String clientLibraryUrl)
By default this is set to point to "https://cdn.jsdelivr.net/sockjs/0.3.4/sockjs.min.js". However it can also be set to point to a URL served by the application.
Note that it's possible to specify a relative URL in which case the URL must be relative to the iframe URL. For example assuming a SockJS endpoint mapped to "/sockjs", and resulting iframe URL "/sockjs/iframe.html", then the relative URL must start with "../../" to traverse up to the location above the SockJS mapping. In case of a prefix-based Servlet mapping one more traversal may be needed.
public SockJsServiceRegistration setStreamBytesLimit(int streamBytesLimit)
The default value is 128K (i.e. 128 * 1024).
public SockJsServiceRegistration setSessionCookieNeeded(boolean sessionCookieNeeded)
This is especially important for IE 8,9 that support XDomainRequest -- a modified AJAX/XHR -- that can do requests across domains but does not send any cookies. In those cases, the SockJS client prefers the "iframe-htmlfile" transport over "xdr-streaming" in order to be able to send cookies.
The default value is "true" to maximize the chance for applications to work correctly in IE 8,9 with support for cookies (and the JSESSIONID cookie in particular). However, an application can choose to set this to "false" if the use of cookies (and HTTP session) is not required.
public SockJsServiceRegistration setHeartbeatTime(long heartbeatTime)
The default value is 25,000 (25 seconds).
public SockJsServiceRegistration setDisconnectDelay(long disconnectDelay)
The default value is 5000.
public SockJsServiceRegistration setHttpMessageCacheSize(int httpMessageCacheSize)
The amount of time between HTTP requests should be relatively brief and will not
exceed the allows disconnect delay (see
setDisconnectDelay(long)
), 5 seconds by default.
The default size is 100.
public SockJsServiceRegistration setWebSocketEnabled(boolean webSocketEnabled)
The default value is "true".
public SockJsServiceRegistration setTransportHandlers(TransportHandler... handlers)
public SockJsServiceRegistration setTransportHandlerOverrides(TransportHandler... handlers)
public SockJsServiceRegistration setInterceptors(HandshakeInterceptor... interceptors)
protected SockJsServiceRegistration setAllowedOrigins(String... allowedOrigins)
Origin
header values.protected SockJsServiceRegistration setAllowedOriginPatterns(String... allowedOriginPatterns)
Origin
pattern header values.public SockJsServiceRegistration setSupressCors(boolean suppressCors)
The default value is "false".
public SockJsServiceRegistration setMessageCodec(SockJsMessageCodec codec)
By default Jackson2SockJsMessageCodec
is used requiring the
Jackson library to be present on the classpath.
codec
- the codec to use.protected SockJsService getSockJsService()
@Nullable protected TaskScheduler getTaskScheduler()