package com.smtaiserver.smtaiserver.web; import org.springframework.context.annotation.Bean; 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 org.springframework.web.socket.handler.TextWebSocketHandler; import org.springframework.web.socket.server.support.HttpSessionHandshakeInterceptor; @Configuration @EnableWebSocket public class SMTWebSocketConfig implements WebSocketConfigurer { @Bean public TextWebSocketHandler webSocketHandler() { return new SMTWebSocketHandler(); } @Override public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) { registry.addHandler(webSocketHandler(), "/ws") .addInterceptors(new HttpSessionHandshakeInterceptor()) .setAllowedOrigins("*"); } }