package com.ltkj.web.websocket;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
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;
|
|
/**
|
* @Company: 西安路泰科技有限公司
|
* @Author: zhaowenxuan
|
* @Date: 2025/6/27 15:47
|
*/
|
@Configuration
|
@EnableWebSocket
|
public class MyWebSocketConfig implements WebSocketConfigurer {
|
@Autowired
|
private WebSockerManager webSockerManager;
|
@Override
|
public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
|
registry.addHandler(webSockerManager, "/ws")
|
// .addInterceptors(tokenHandshakeInterceptor)
|
.setAllowedOrigins("*"); // 允许跨域
|
}
|
}
|