Explorar el Código

websocket 问题

huangxingxing hace 8 meses
padre
commit
8b025a5bf5
Se han modificado 1 ficheros con 7 adiciones y 1 borrados
  1. 7 1
      src/view/InfoDialoges.vue

+ 7 - 1
src/view/InfoDialoges.vue

@@ -486,7 +486,7 @@ const props = defineProps({
 });
 let startlog=ref('0');
 let shigtext = ref('');
-let websock = ref(null);
+let websock = null;
 let times = ref({
     lockReconnect: false, //是否真正建立连接
     timeout: 28 * 1000, //30秒一次心跳
@@ -1121,7 +1121,13 @@ async function fetchFileContent() {
 function initWebSocket() {
     //初始化weosocket
     // const wsuri = "ws://192.168.0.43:8087//websocket?projectId="+this.pid; ws://192.168.0.131/diswebsocket?projectId=5
+    
+    if(websock!=null){
+        websock.close();
+        websock=null;
+    }
     const wsurl = import.meta.env.VITE_WEBSOCKET_URL + aid.value
+    console.log("initWebSocket",wsurl)
     websock = new WebSocket(wsurl);
     websock.onopen = websocketonopen;
     websock.onmessage = websocketonmessage;