host优化
This commit is contained in:
		
							parent
							
								
									699317b1fe
								
							
						
					
					
						commit
						1be1d806f7
					
				| @ -8,45 +8,52 @@ export async function sendMsg(val) { | ||||
| } | ||||
| 
 | ||||
| export async function getUDP() { | ||||
|   console.log(` getUDP  enter`); | ||||
|   getSyncData('IpConfigTable').then((result: Array<any>) => { | ||||
|     if (result.length) { | ||||
|       console.log(` getUDP  has IPConfigTable `); | ||||
|       if (globalThis.udpClient && globalThis.udpClient.closeUdp) { | ||||
|         console.log(` getUDP  has udclent close and rebind `); | ||||
|         globalThis.udpClient.closeUdp(() => { | ||||
|           setTimeout(() => { | ||||
|             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}` | ||||
|             // globalThis.udpClient.onError_resend(globalThis.udpClient.onMessage_1?globalThis.udpClient.onMessage_1:()=>{})
 | ||||
|           }, 1000) | ||||
|         }) | ||||
|       } | ||||
|       else { | ||||
|         // 未绑定
 | ||||
|         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) | ||||
|         udpClient.bindUdp() | ||||
|         udpClient.sendMsg('111') | ||||
|         globalThis.host = `http://${result[0].centerIp}:${result[0].centerPort}` | ||||
|         // udpClient.onError_resend(globalThis.udpClient.onMessage_1?globalThis.udpClient.onMessage_1:()=>{})
 | ||||
|         globalThis.udpClient = udpClient | ||||
|         getChuankouFn() | ||||
|       } | ||||
|   return new Promise((reslove,reject)=>{ | ||||
|     getSyncData('IpConfigTable').then((result: Array<any>) => { | ||||
|       if (result.length) { | ||||
|         console.log(` getUDP  has IPConfigTable `); | ||||
|         if (globalThis.udpClient && globalThis.udpClient.closeUdp) { | ||||
|           console.log(` getUDP  has udclent close and rebind `); | ||||
|           globalThis.udpClient.closeUdp(() => { | ||||
|             setTimeout(() => { | ||||
|               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) | ||||
|           }) | ||||
|         } | ||||
|         else { | ||||
|           // 未绑定
 | ||||
|           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) | ||||
|           udpClient.bindUdp() | ||||
|           udpClient.sendMsg('111') | ||||
|           globalThis.host = `http://${result[0].centerIp}:${result[0].centerPort}` | ||||
|           // udpClient.onError_resend(globalThis.udpClient.onMessage_1?globalThis.udpClient.onMessage_1:()=>{})
 | ||||
|           globalThis.udpClient = udpClient | ||||
|           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 = '' | ||||
|     } | ||||
|         } | ||||
| 
 | ||||
|       } 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('') | ||||
| 
 | ||||
|       } | ||||
|     }) | ||||
|   }) | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| export async function getUDP2() { | ||||
|  | ||||
| @ -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