Przeglądaj źródła

train-server 调整

zhanghaijun 2 lat temu
rodzic
commit
af800a0b5c

+ 6 - 0
train-server/src/main/resources/application.yml

@@ -26,3 +26,9 @@ spring:
     expose-request-attributes: true
     expose-session-attributes: true
     expose-spring-macro-helpers: true
+
+---
+websocket:
+  enabled: true
+  path: /websocket
+  allowedOrigins: '*'

+ 2 - 2
train-server/src/main/resources/templates/webSocket.html

@@ -15,12 +15,12 @@
             console.log("您的浏览器支持WebSocket");
             //实现化WebSocket对象,指定要连接的服务器地址与端口,建立连接.
             // var socketUrl = "http://localhost:8086/socket/" + $("#uid").val();
-            var socketUrl = "http://localhost:8086/websocket/";
+            var socketUrl = "http://localhost:8086/websocket";
             //将https与http协议替换为ws协议
             socketUrl = socketUrl.replace("https", "ws").replace("http", "ws");
             console.log(socketUrl);
             if (socket != null) {
-                socket.close();8
+                socket.close();
                 socket = null;
             }
             socket = new WebSocket(socketUrl);