Compare commits
4 Commits
abc48bd774
...
23ea400ee3
| Author | SHA1 | Date | |
|---|---|---|---|
| 23ea400ee3 | |||
| 60a55f585d | |||
| 1be1d806f7 | |||
| 699317b1fe |
@ -14,7 +14,16 @@ export async function getTCP() {
|
||||
await globalThis.TcpClient.rebindTcp(result[0].tcplocalIp, result[0].tcplocalIpPort,result[0].tcpOppositeIp,result[0].tcpOppositePort)
|
||||
await globalThis.TcpClient.connectTcp()
|
||||
await globalThis.TcpClient.sendMsg('1002')//1002
|
||||
globalThis.TcpClient.onError()
|
||||
globalThis.TcpClient.onError((val)=>{
|
||||
setTimeout(()=>{
|
||||
globalThis.TcpClient.sendMsg('1002')//1002
|
||||
if(val){
|
||||
// const msg=val.substring(5,val.length-1)
|
||||
console.log('socketTag[PLC.UdpClient] status:',globalThis.udpClient.getStatus())
|
||||
globalThis.udpClient?.sendMsg(val)
|
||||
}
|
||||
},1000)
|
||||
})
|
||||
await globalThis.TcpClient.onMessage((val)=>{
|
||||
setTimeout(()=>{
|
||||
globalThis.TcpClient.sendMsg('1002')//1002
|
||||
@ -35,14 +44,20 @@ export async function getTCP() {
|
||||
await globalThis.TcpClient.bindTcp()
|
||||
await globalThis.TcpClient.connectTcp()
|
||||
await globalThis.TcpClient.sendMsg('1002')//1002
|
||||
globalThis.TcpClient.onError()
|
||||
globalThis.TcpClient.onError((val)=>{
|
||||
hilog.info(0x0000, 'testTag', "valvalval2" + JSON.stringify(val));
|
||||
setTimeout(()=>{
|
||||
globalThis.TcpClient.sendMsg('1002')//1002
|
||||
if(val&& globalThis.udpClient?.sendMsg){
|
||||
globalThis.udpClient?.sendMsg(val)
|
||||
}
|
||||
},1000)
|
||||
})
|
||||
await globalThis.TcpClient.onMessage((val)=>{
|
||||
hilog.info(0x0000, 'testTag', "valvalval2" + JSON.stringify(val));
|
||||
setTimeout(()=>{
|
||||
globalThis.TcpClient.sendMsg('1002')//1002
|
||||
if(val&& globalThis.udpClient?.sendMsg){
|
||||
// const msg=val.substring(5,val.length-1)
|
||||
|
||||
globalThis.udpClient?.sendMsg(val)
|
||||
}
|
||||
},1000)
|
||||
|
||||
@ -8,7 +8,7 @@ export async function sendMsg(val) {
|
||||
}
|
||||
|
||||
export async function getUDP() {
|
||||
console.log(` getUDP enter`);
|
||||
return new Promise((reslove,reject)=>{
|
||||
getSyncData('IpConfigTable').then((result: Array<any>) => {
|
||||
if (result.length) {
|
||||
console.log(` getUDP has IPConfigTable `);
|
||||
@ -19,6 +19,7 @@ export async function getUDP() {
|
||||
globalThis.udpClient.rebindUdp(result[0].udplocalIp, result[0].udplocalIpPort, result[0].udpOppositeIp, result[0].udpOppositeIpPort)
|
||||
globalThis.udpClient.sendMsg('111', null)
|
||||
globalThis.host = `http://${result[0].centerIp}:${result[0].centerPort}`
|
||||
reslove(`http://${result[0].centerIp}:${result[0].centerPort}`)
|
||||
// globalThis.udpClient.onError_resend(globalThis.udpClient.onMessage_1?globalThis.udpClient.onMessage_1:()=>{})
|
||||
}, 1000)
|
||||
})
|
||||
@ -33,6 +34,8 @@ export async function getUDP() {
|
||||
// udpClient.onError_resend(globalThis.udpClient.onMessage_1?globalThis.udpClient.onMessage_1:()=>{})
|
||||
globalThis.udpClient = udpClient
|
||||
getChuankouFn()
|
||||
reslove(`http://${result[0].centerIp}:${result[0].centerPort}`)
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
@ -45,8 +48,12 @@ export async function getUDP() {
|
||||
globalThis.udpClient = {}
|
||||
// globalThis.udpClient.onMessage_1 = () => {}
|
||||
globalThis.host = ''
|
||||
reslove('')
|
||||
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
export async function getUDP2() {
|
||||
|
||||
@ -24,7 +24,11 @@ export default class TcpClient {
|
||||
onError(callback?){
|
||||
this.tcp.on('error', err => {
|
||||
console.log(TAG,'tcpOnerror', JSON.stringify(err))
|
||||
callback&&callback()
|
||||
setTimeout(async ()=>{
|
||||
await this.bindTcp()
|
||||
await this.connectTcp()
|
||||
this.onMessage(callback)
|
||||
},2000)
|
||||
// this.closeUdp(()=>{
|
||||
// this.bindUdp()
|
||||
// })
|
||||
@ -107,12 +111,13 @@ export default class TcpClient {
|
||||
resolve(true)
|
||||
}).catch(err => {
|
||||
globalThis.getCloseTcp=true
|
||||
|
||||
setTimeout(()=>{
|
||||
this.connectTcp()
|
||||
},2000)
|
||||
console.log('testTagconnect,error')
|
||||
resolve(false)
|
||||
|
||||
});
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
sendMsg(msg: string) {
|
||||
|
||||
@ -269,13 +269,13 @@ struct Index {
|
||||
}
|
||||
}
|
||||
|
||||
onPageShow() {
|
||||
async onPageShow() {
|
||||
this.loading = false
|
||||
this.createAlbum()
|
||||
this.userAuth();
|
||||
getUDP()
|
||||
getUDP2()
|
||||
await getUDP()
|
||||
await getUDP2()
|
||||
this.num=0
|
||||
this.userAuth();
|
||||
clearInterval(this.interval)
|
||||
this.interval = setInterval(() => {
|
||||
this.num++
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user