25 lines
864 B
Java
25 lines
864 B
Java
|
|
package com.wecom.robot.config;
|
||
|
|
|
||
|
|
import com.wecom.robot.websocket.CsWebSocketHandler;
|
||
|
|
import org.springframework.context.annotation.Configuration;
|
||
|
|
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
|
||
|
|
public class WebSocketConfig implements WebSocketConfigurer {
|
||
|
|
|
||
|
|
private final CsWebSocketHandler csWebSocketHandler;
|
||
|
|
|
||
|
|
public WebSocketConfig(CsWebSocketHandler csWebSocketHandler) {
|
||
|
|
this.csWebSocketHandler = csWebSocketHandler;
|
||
|
|
}
|
||
|
|
|
||
|
|
@Override
|
||
|
|
public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
|
||
|
|
registry.addHandler(csWebSocketHandler, "/ws/cs/*")
|
||
|
|
.setAllowedOrigins("*");
|
||
|
|
}
|
||
|
|
}
|