package com.shlanbao.tzsc.pms.websocket;
|
|
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Configuration;
|
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
import org.springframework.web.socket.config.annotation.EnableWebSocket;
|
import org.springframework.web.socket.config.annotation.WebSocketConfigurer;
|
import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry;
|
|
/**
|
*/
|
@Configuration
|
@EnableWebSocket
|
@EnableWebMvc
|
public class WebSocketConfig implements WebSocketConfigurer {
|
public void registerWebSocketHandlers(WebSocketHandlerRegistry webSocketHandlerRegistry) {
|
webSocketHandlerRegistry.addHandler(myHandler(),"/websocket").addInterceptors(new HandshakeInterceptor());
|
webSocketHandlerRegistry.addHandler(myHandler(),"/sockjs/websocket").addInterceptors(new HandshakeInterceptor()).withSockJS();
|
}
|
@Bean
|
public MyWebSocketHandler myHandler(){
|
return new MyWebSocketHandler();
|
}
|
}
|