Top Description Methods
org.springframework.web.socket.config.annotation

public Interface WebSocketHandlerRegistration

Known Direct Implementers
org.springframework.web.socket.config.annotation.AbstractWebSocketHandlerRegistration
Imports
java.util.List, org.springframework.web.cors.CorsConfiguration, org.springframework.web.socket.WebSocketHandler, org.springframework.web.socket.server.HandshakeHandler, .HandshakeInterceptor

Provides methods for configuring a WebSocket handler.
Author
Rossen Stoyanchev
Since
4.0

Method Summary

Modifier and TypeMethod and Description
public WebSocketHandlerRegistration
addHandler(WebSocketHandler handler, String... paths)

Add more handlers that will share the same configuration (interceptors, SockJS config, etc).

public WebSocketHandlerRegistration
addInterceptors(HandshakeInterceptor... interceptors)

Configure interceptors for the handshake request.

public WebSocketHandlerRegistration
setAllowedOriginPatterns(String... originPatterns)

Alternative to setAllowedOrigins(String...) that supports more flexible patterns for specifying the origins for which cross-origin requests are allowed from a browser.

public WebSocketHandlerRegistration
setAllowedOrigins(String... origins)

Set the origins for which cross-origin requests are allowed from a browser.

public WebSocketHandlerRegistration
setHandshakeHandler(HandshakeHandler handshakeHandler)

Configure the HandshakeHandler to use.

public SockJsServiceRegistration
withSockJS()

Enable SockJS fallback options.

Method Detail

addHandlerback to summary
public WebSocketHandlerRegistration addHandler(WebSocketHandler handler, String... paths)

Add more handlers that will share the same configuration (interceptors, SockJS config, etc).

addInterceptorsback to summary
public WebSocketHandlerRegistration addInterceptors(HandshakeInterceptor... interceptors)

Configure interceptors for the handshake request.

setAllowedOriginPatternsback to summary
public WebSocketHandlerRegistration setAllowedOriginPatterns(String... originPatterns)

Alternative to setAllowedOrigins(String...) that supports more flexible patterns for specifying the origins for which cross-origin requests are allowed from a browser. Please, refer to CorsConfiguration#setAllowedOriginPatterns(List) for format details and other considerations.

By default this is not set.

Since
5.3.5
setAllowedOriginsback to summary
public WebSocketHandlerRegistration setAllowedOrigins(String... origins)

Set the origins for which cross-origin requests are allowed from a browser. Please, refer to CorsConfiguration#setAllowedOrigins(List) for format details and considerations, and keep in mind that the CORS spec does not allow use of "*" with allowCredentials=true. For more flexible origin patterns use setAllowedOriginPatterns instead.

By default, no origins are allowed. When allowedOriginPatterns is also set, then that takes precedence over this property.

Note when SockJS is enabled and origins are restricted, transport types that do not allow to check request origin (Iframe based transports) are disabled. As a consequence, IE 6 to 9 are not supported when origins are restricted.

Since
4.1.2
See Also
setAllowedOriginPatterns(String...), RFC 6454: The Web Origin Concept, SockJS supported transports by browser
setHandshakeHandlerback to summary
public WebSocketHandlerRegistration setHandshakeHandler(HandshakeHandler handshakeHandler)

Configure the HandshakeHandler to use.

withSockJSback to summary
public SockJsServiceRegistration withSockJS()

Enable SockJS fallback options.