You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
1.2 KiB
30 lines
1.2 KiB
package com.wsk.controller.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.servlet.config.annotation.WebMvcConfigurerAdapter;
|
|
import org.springframework.web.socket.config.annotation.EnableWebSocket;
|
|
import org.springframework.web.socket.config.annotation.WebSocketConfigurer;
|
|
import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry;
|
|
|
|
/**
|
|
* Created by wsk1103 on 2017/5/22.
|
|
*/
|
|
@Configuration
|
|
@EnableWebMvc
|
|
@EnableWebSocket
|
|
public class WebSocketConfig extends WebMvcConfigurerAdapter implements WebSocketConfigurer {
|
|
@Override
|
|
public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
|
|
//WebIM WebSocket通道
|
|
registry.addHandler(chatWebSocketHandler(),"/webSocketIMServer");
|
|
registry.addHandler(chatWebSocketHandler(),"/sockjs/webSocketIMServer");
|
|
registry.addHandler(chatWebSocketHandler(), "/sockjs/webSocketIMServer").withSockJS();
|
|
}
|
|
@Bean
|
|
public ChatWebSocketHandler chatWebSocketHandler() {
|
|
return new ChatWebSocketHandler();
|
|
}
|
|
}
|