Compare commits
No commits in common. "23ea400ee392e31ec84f5dcd148abeef9555bc3c" and "abc48bd774b67b84dc2ff67d56a7b4e7b5110750" have entirely different histories.
23ea400ee3
...
abc48bd774
@ -14,16 +14,7 @@ export async function getTCP() {
|
|||||||
await globalThis.TcpClient.rebindTcp(result[0].tcplocalIp, result[0].tcplocalIpPort,result[0].tcpOppositeIp,result[0].tcpOppositePort)
|
await globalThis.TcpClient.rebindTcp(result[0].tcplocalIp, result[0].tcplocalIpPort,result[0].tcpOppositeIp,result[0].tcpOppositePort)
|
||||||
await globalThis.TcpClient.connectTcp()
|
await globalThis.TcpClient.connectTcp()
|
||||||
await globalThis.TcpClient.sendMsg('1002')//1002
|
await globalThis.TcpClient.sendMsg('1002')//1002
|
||||||
globalThis.TcpClient.onError((val)=>{
|
globalThis.TcpClient.onError()
|
||||||
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)=>{
|
await globalThis.TcpClient.onMessage((val)=>{
|
||||||
setTimeout(()=>{
|
setTimeout(()=>{
|
||||||
globalThis.TcpClient.sendMsg('1002')//1002
|
globalThis.TcpClient.sendMsg('1002')//1002
|
||||||
@ -44,20 +35,14 @@ export async function getTCP() {
|
|||||||
await globalThis.TcpClient.bindTcp()
|
await globalThis.TcpClient.bindTcp()
|
||||||
await globalThis.TcpClient.connectTcp()
|
await globalThis.TcpClient.connectTcp()
|
||||||
await globalThis.TcpClient.sendMsg('1002')//1002
|
await globalThis.TcpClient.sendMsg('1002')//1002
|
||||||
globalThis.TcpClient.onError((val)=>{
|
globalThis.TcpClient.onError()
|
||||||
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)=>{
|
await globalThis.TcpClient.onMessage((val)=>{
|
||||||
hilog.info(0x0000, 'testTag', "valvalval2" + JSON.stringify(val));
|
hilog.info(0x0000, 'testTag', "valvalval2" + JSON.stringify(val));
|
||||||
setTimeout(()=>{
|
setTimeout(()=>{
|
||||||
globalThis.TcpClient.sendMsg('1002')//1002
|
globalThis.TcpClient.sendMsg('1002')//1002
|
||||||
if(val&& globalThis.udpClient?.sendMsg){
|
if(val&& globalThis.udpClient?.sendMsg){
|
||||||
|
// const msg=val.substring(5,val.length-1)
|
||||||
|
|
||||||
globalThis.udpClient?.sendMsg(val)
|
globalThis.udpClient?.sendMsg(val)
|
||||||
}
|
}
|
||||||
},1000)
|
},1000)
|
||||||
|
|||||||
@ -8,52 +8,45 @@ export async function sendMsg(val) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function getUDP() {
|
export async function getUDP() {
|
||||||
return new Promise((reslove,reject)=>{
|
console.log(` getUDP enter`);
|
||||||
getSyncData('IpConfigTable').then((result: Array<any>) => {
|
getSyncData('IpConfigTable').then((result: Array<any>) => {
|
||||||
if (result.length) {
|
if (result.length) {
|
||||||
console.log(` getUDP has IPConfigTable `);
|
console.log(` getUDP has IPConfigTable `);
|
||||||
if (globalThis.udpClient && globalThis.udpClient.closeUdp) {
|
if (globalThis.udpClient && globalThis.udpClient.closeUdp) {
|
||||||
console.log(` getUDP has udclent close and rebind `);
|
console.log(` getUDP has udclent close and rebind `);
|
||||||
globalThis.udpClient.closeUdp(() => {
|
globalThis.udpClient.closeUdp(() => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
globalThis.udpClient.rebindUdp(result[0].udplocalIp, result[0].udplocalIpPort, result[0].udpOppositeIp, result[0].udpOppositeIpPort)
|
globalThis.udpClient.rebindUdp(result[0].udplocalIp, result[0].udplocalIpPort, result[0].udpOppositeIp, result[0].udpOppositeIpPort)
|
||||||
globalThis.udpClient.sendMsg('111', null)
|
globalThis.udpClient.sendMsg('111', null)
|
||||||
globalThis.host = `http://${result[0].centerIp}:${result[0].centerPort}`
|
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:()=>{})
|
||||||
// globalThis.udpClient.onError_resend(globalThis.udpClient.onMessage_1?globalThis.udpClient.onMessage_1:()=>{})
|
}, 1000)
|
||||||
}, 1000)
|
})
|
||||||
})
|
}
|
||||||
}
|
else {
|
||||||
else {
|
// 未绑定
|
||||||
// 未绑定
|
console.log(` getUDP has no udclent and bind `);
|
||||||
console.log(` getUDP has no udclent and bind `);
|
const udpClient: UdpClientByCenter = new UdpClientByCenter(result[0].udplocalIp, result[0].udplocalIpPort, result[0].udpOppositeIp, result[0].udpOppositeIpPort)
|
||||||
const udpClient: UdpClientByCenter = new UdpClientByCenter(result[0].udplocalIp, result[0].udplocalIpPort, result[0].udpOppositeIp, result[0].udpOppositeIpPort)
|
udpClient.bindUdp()
|
||||||
udpClient.bindUdp()
|
udpClient.sendMsg('111')
|
||||||
udpClient.sendMsg('111')
|
globalThis.host = `http://${result[0].centerIp}:${result[0].centerPort}`
|
||||||
globalThis.host = `http://${result[0].centerIp}:${result[0].centerPort}`
|
// udpClient.onError_resend(globalThis.udpClient.onMessage_1?globalThis.udpClient.onMessage_1:()=>{})
|
||||||
// udpClient.onError_resend(globalThis.udpClient.onMessage_1?globalThis.udpClient.onMessage_1:()=>{})
|
globalThis.udpClient = udpClient
|
||||||
globalThis.udpClient = udpClient
|
getChuankouFn()
|
||||||
getChuankouFn()
|
|
||||||
reslove(`http://${result[0].centerIp}:${result[0].centerPort}`)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
console.log(` getUDP has no IPConfigTable `);
|
|
||||||
// if(globalThis.udpClient)
|
|
||||||
// {
|
|
||||||
// console.log(` getUDP2 has IPConfigTable ,has udpClient ,close it`);
|
|
||||||
// globalThis.udpClient.closeUdp(async ()=>{ })
|
|
||||||
// }
|
|
||||||
globalThis.udpClient = {}
|
|
||||||
// globalThis.udpClient.onMessage_1 = () => {}
|
|
||||||
globalThis.host = ''
|
|
||||||
reslove('')
|
|
||||||
|
|
||||||
}
|
}
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
|
} else {
|
||||||
|
console.log(` getUDP has no IPConfigTable `);
|
||||||
|
// if(globalThis.udpClient)
|
||||||
|
// {
|
||||||
|
// console.log(` getUDP2 has IPConfigTable ,has udpClient ,close it`);
|
||||||
|
// globalThis.udpClient.closeUdp(async ()=>{ })
|
||||||
|
// }
|
||||||
|
globalThis.udpClient = {}
|
||||||
|
// globalThis.udpClient.onMessage_1 = () => {}
|
||||||
|
globalThis.host = ''
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getUDP2() {
|
export async function getUDP2() {
|
||||||
|
|||||||
@ -24,11 +24,7 @@ export default class TcpClient {
|
|||||||
onError(callback?){
|
onError(callback?){
|
||||||
this.tcp.on('error', err => {
|
this.tcp.on('error', err => {
|
||||||
console.log(TAG,'tcpOnerror', JSON.stringify(err))
|
console.log(TAG,'tcpOnerror', JSON.stringify(err))
|
||||||
setTimeout(async ()=>{
|
callback&&callback()
|
||||||
await this.bindTcp()
|
|
||||||
await this.connectTcp()
|
|
||||||
this.onMessage(callback)
|
|
||||||
},2000)
|
|
||||||
// this.closeUdp(()=>{
|
// this.closeUdp(()=>{
|
||||||
// this.bindUdp()
|
// this.bindUdp()
|
||||||
// })
|
// })
|
||||||
@ -111,13 +107,12 @@ export default class TcpClient {
|
|||||||
resolve(true)
|
resolve(true)
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
globalThis.getCloseTcp=true
|
globalThis.getCloseTcp=true
|
||||||
setTimeout(()=>{
|
|
||||||
this.connectTcp()
|
|
||||||
},2000)
|
|
||||||
console.log('testTagconnect,error')
|
|
||||||
|
|
||||||
|
console.log('testTagconnect,error')
|
||||||
|
resolve(false)
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sendMsg(msg: string) {
|
sendMsg(msg: string) {
|
||||||
|
|||||||
@ -269,13 +269,13 @@ struct Index {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async onPageShow() {
|
onPageShow() {
|
||||||
this.loading = false
|
this.loading = false
|
||||||
this.createAlbum()
|
this.createAlbum()
|
||||||
await getUDP()
|
|
||||||
await getUDP2()
|
|
||||||
this.num=0
|
|
||||||
this.userAuth();
|
this.userAuth();
|
||||||
|
getUDP()
|
||||||
|
getUDP2()
|
||||||
|
this.num=0
|
||||||
clearInterval(this.interval)
|
clearInterval(this.interval)
|
||||||
this.interval = setInterval(() => {
|
this.interval = setInterval(() => {
|
||||||
this.num++
|
this.num++
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user