示例#1
0
 public void TestAndReconnectServer()
 {
     while (true)
     {
         Thread.Sleep(5000);
         try
         {
             if (Global.P2PServerTcp != null && Global.P2PServerTcp.Connected)
             {
                 Send_0x0052 sendPacket = new Send_0x0052();
                 int         count      = Global.P2PServerTcp.Client.Send(sendPacket.PackData());
             }
             else
             {
                 ConnectServer();
             }
         }
         catch (Exception ex)
         {
             LogUtils.Warning($"【断线重连】错误消息:{Environment.NewLine}{ex.ToString()}");
             try
             {
                 Global.P2PServerTcp.Close();
             }
             catch { }
             Global.P2PServerTcp = null;
             ConnectServer();
         }
     }
 }