songjun
2022-07-15 868abf68ab0e737de85abe2b3ceab8c158952a3d
src/samples/sockteStomp.ts
@@ -176,27 +176,24 @@
        stompClient.send(`/app/workstation/config/set/${clientCode}/${pcName}`,{},JSON.stringify({"clientCode":clientCode,"machineName":pcName}))
        
    }
<<<<<<< HEAD
    // 更新sockte链接状态
    sockteStore().setsockteIsLink(true)
    console.log(sockteStore().isLink)
    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){
>>>>>>> 5fc7472d0ec6bff69b874f33eeccc30541f7f6df
        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}));
        // 更新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}));
            }
        })
                }
            })
        }
    }
}
@@ -207,12 +204,12 @@
const error_callback=function(error:any){
    console.log('链接错误',error);
    setTimeout(()=>{
        console.log('10秒之后重连',sockteNum++)
        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)=>{