Annotation Interface EnableWebSocket
@Retention(RUNTIME)
@Target(TYPE)
@Documented
@Import(DelegatingWebSocketConfiguration.class)
public @interface EnableWebSocket
Add this annotation to an
@Configuration class to configure
processing WebSocket requests. A typical configuration would look like this:
@Configuration
@EnableWebSocket
public class MyWebSocketConfig {
}
Customize the imported configuration by implementing the
WebSocketConfigurer interface:
@Configuration
@EnableWebSocket
public class MyConfiguration implements WebSocketConfigurer {
@Override
public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
registry.addHandler(echoWebSocketHandler(), "/echo").withSockJS();
}
@Override
public WebSocketHandler echoWebSocketHandler() {
return new EchoWebSocketHandler();
}
}
- Since:
- 4.0
- Author:
- Rossen Stoyanchev