Helius
2022-03-29 d4a85f010f6b17caed4edf1e56b742c6c4e20b02
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package cc.mrbird.febs.websocket;
 
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;
 
import javax.annotation.Resource;
 
/**
 *
 * @author xxx
 * @date 2020-09-01
 **/
@Configuration
@EnableWebSocket
public class WebSocketConfig implements WebSocketConfigurer {
 
    @Resource
    private HttpAuthHandler httpAuthHandler;
    @Resource
    private WsAuthInterceptor wsAuthInterceptor;
 
    @Override
    public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
        registry.addHandler(httpAuthHandler, "wsxg")
                .addInterceptors(wsAuthInterceptor)
                .setAllowedOrigins("*");
    }
}