| | |
| | | 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' |
| | |
| | | const sound = require("sound-play"); |
| | | |
| | | |
| | | let sockteNum=0 |
| | | |
| | | |
| | | interface device{ |
| | |
| | | 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})); |
| | | |
| | | } |
| | | }) |
| | | } |
| | | }) |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | 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) |
| | | stompClient.connect({}, connectCallback,error_callback) |
| | | },10000) |
| | | },60000) |
| | | } |
| | | // 创建客户端链接 |
| | | 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) |