参考文章:
http://blog.csdn.net/pacosonswjtu/article/details/51914567
http://blog.csdn.net/valenon/article/details/45892377
在这篇文章找到想要的(握手的时候传参数)
http://lippeng.iteye.com/blog/2299509
maven依赖
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-websocket</artifactId>
</dependency>
配置WebSocketConfig
@Configuration
@EnableWebSocket
public class WebSocketConfig implements WebSocketConfigurer{
@Override
public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
registry.addHandler(getTextHandler(), "/websocket/");
} // 将 ChatTextHandler 处理器 映射到 /websocket/路径下.
@Bean
public ChatTextHandler getTextHandler() {
return new ChatTextHandler();
}
}
网友评论