Annotation 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();
           }

           @Bean
           public WebSocketHandler echoWebSocketHandler() {
         return new EchoWebSocketHandler();
     }
 }
 
Since:
4.0
Author:
Rossen Stoyanchev