|
@@ -0,0 +1,44 @@
|
|
|
+package com.jihengbel.intelligent.applicationtask.websocket;
|
|
|
+
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.context.annotation.Bean;
|
|
|
+import org.springframework.context.annotation.Configuration;
|
|
|
+import org.springframework.scheduling.TaskScheduler;
|
|
|
+import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+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
|
|
|
+@RestController
|
|
|
+public class WebSocketConfig implements WebSocketConfigurer {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private WebSocketHandler webSocketHandler;
|
|
|
+ @Autowired
|
|
|
+ private WebSocketHandshakeInterceptor webSocketInterceptor;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
|
|
|
+ registry
|
|
|
+ .addHandler(webSocketHandler, "ws/pad")
|
|
|
+ .addInterceptors(webSocketInterceptor)
|
|
|
+ .setAllowedOrigins("*");
|
|
|
+ }
|
|
|
+
|
|
|
+ @Bean
|
|
|
+ public TaskScheduler taskScheduler(){
|
|
|
+ ThreadPoolTaskScheduler taskScheduler=new ThreadPoolTaskScheduler();
|
|
|
+ taskScheduler.setPoolSize(40);
|
|
|
+ taskScheduler.initialize();
|
|
|
+ return taskScheduler;
|
|
|
+ }
|
|
|
+
|
|
|
+//
|
|
|
+// @Bean
|
|
|
+// public ServerEndpointExporter serverEndpointExporter(){
|
|
|
+// return new ServerEndpointExporter();
|
|
|
+// }
|
|
|
+}
|