mirror of
https://github.com/Sagit-chu/flvx.git
synced 2026-09-29 16:06:36 +08:00
41 lines
1.3 KiB
Java
41 lines
1.3 KiB
Java
package com.admin.config;
|
|
|
|
import com.admin.common.utils.WebSocketServer;
|
|
import org.springframework.context.annotation.Bean;
|
|
import org.springframework.context.annotation.Configuration;
|
|
import org.springframework.web.socket.WebSocketHandler;
|
|
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.boot.web.servlet.ServletContextInitializer;
|
|
import org.springframework.context.annotation.Bean;
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
|
import javax.servlet.ServletContext;
|
|
import javax.servlet.ServletException;
|
|
import javax.annotation.Resource;
|
|
|
|
|
|
@Configuration
|
|
@EnableWebSocket
|
|
public class WebSocketConfig implements WebSocketConfigurer {
|
|
|
|
@Resource
|
|
private WebSocketInterceptor webSocketInterceptor;
|
|
|
|
@Override
|
|
public void registerWebSocketHandlers(WebSocketHandlerRegistry webSocketHandlerRegistry) {
|
|
webSocketHandlerRegistry
|
|
.addHandler(myHandler(), "/system-info")
|
|
.setAllowedOrigins("*")
|
|
.addInterceptors(webSocketInterceptor);
|
|
}
|
|
|
|
|
|
@Bean
|
|
public WebSocketHandler myHandler() {
|
|
return new WebSocketServer();
|
|
}
|
|
|
|
}
|