From 6f509dd2ad48541331a115aa8f59e55dd351ed13 Mon Sep 17 00:00:00 2001
From: chenyc <501753378@qq.com>
Date: 星期五, 15 七月 2022 21:00:52 +0800
Subject: [PATCH] gengxin

---
 src/samples/sockteStomp.ts |   32 ++++++++++++++++++--------------
 1 files changed, 18 insertions(+), 14 deletions(-)

diff --git a/src/samples/sockteStomp.ts b/src/samples/sockteStomp.ts
index bb325ce..706b288 100644
--- a/src/samples/sockteStomp.ts
+++ b/src/samples/sockteStomp.ts
@@ -1,7 +1,7 @@
 import Stomp from 'stompjs'
 import os from 'os'
 import { ipcRenderer } from 'electron'
-var stompClient: Stomp.Client | null=null
+let stompClient: Stomp.Client | null=null
 
 import { userInfoStore } from '@/stores/userInfo'
 import { patientInfoStore } from '@/stores/patient'
@@ -10,6 +10,7 @@
 const sound = require("sound-play");
 
 
+let sockteNum=0
 
 
 interface device{
@@ -175,20 +176,24 @@
         stompClient.send(`/app/workstation/config/set/${clientCode}/${pcName}`,{},JSON.stringify({"clientCode":clientCode,"machineName":pcName}))
         
     }
-    
     // 更新sockte链接状态
     sockteStore().setsockteIsLink(true)
     console.log(sockteStore().isLink)
-    console.log(devices)
-    if(devices!==undefined&&devices!=null &&devices.length>0){
-        devices.forEach(de=>{
-            if(stompClient!==null){
-                stompClient.subscribe(`/queue/${clientCode}/${de.deviceName}/result`,callback)
-                stompClient.subscribe(`/queue/${clientCode}/${de.deviceName}/keepalive`,callbackState)
-                stompClient.send(`/app/device/request/${clientCode}/${de.deviceName}`, {}, JSON.stringify({"deviceNumber":de.deviceName}));
+    if(devices!==undefined&&devices.length>0){
+        // 更新sockte链接状态
+        sockteStore().setsockteIsLink(true)
+        console.log(sockteStore().isLink)
+        console.log(devices)
+        if(devices!==undefined&&devices!=null &&devices.length>0){
+            devices.forEach(de=>{
+                if(stompClient!==null){
+                    stompClient.subscribe(`/queue/${clientCode}/${de.deviceName}/result`,callback)
+                    // stompClient.subscribe(`/queue/${clientCode}/${de.deviceName}/keepalive`,callbackState)
+                    stompClient.send(`/app/device/request/${clientCode}/${de.deviceName}`, {}, JSON.stringify({"deviceNumber":de.deviceName}));
 
-            } 
-        })
+                } 
+            })
+        }
     }
 }
 
@@ -199,8 +204,7 @@
 const error_callback=function(error:any){
     console.log('链接错误',error);
     setTimeout(()=>{
-        console.log('10秒之后重连')
-        console.log(devices,'设备列表')
+        console.log('10秒之后重连',sockteNum++)
         const socket = new WebSocket('ws://hemobs.icoldchain.cn/broadcast')
         stompClient?.disconnect(disconnectCallBack,{})
         stompClient = Stomp.over(socket)
@@ -211,7 +215,7 @@
 const creatorClient=(devices2:any,clientCode2:any)=>{
     devices=devices2
     clientCode=clientCode2
-    console.log(devices,'设备列表')
+    console.log(devices,'设备列表','chong')
     const socket = new WebSocket('ws://hemobs.icoldchain.cn/broadcast')
     stompClient = Stomp.over(socket)
     stompClient.connect({}, connectCallback,error_callback)

--
Gitblit v1.8.0