Exemple #1
0
        static void TickProcess()
        {
            int i = 0;

            while (true)
            {
                if (isRun)
                {
                    if (ConnectRecvTime.AddSeconds(30) < ConnectSendTime)
                    {
                        //服务器断开
                        isRun = false;
                        CallBackEvent.ServerDisconnect();
                    }
                    if (i > 10)
                    {
                        i = 0;
                        ConnectServer();
                    }
                    i++;
                }
                else
                {
                    ConnectServer();
                }
                Thread.Sleep(1000);
            }
        }
Exemple #2
0
        static void CheckOnline(object obj)
        {
            while (true)
            {
                try
                {
                    UDPClientItemBusiness.ClientItem item = (UDPClientItemBusiness.ClientItem)obj;
                    //非雷达注册客户都清理了
                    var clients = clientList.Where(p => p.HeatTime < DateTime.Now.AddSeconds(0 - XCCloudService.Common.CommonConfig.RadarOffLineTimeLong * 2));
                    if (clients.Count() > 0)
                    {
                        foreach (UDPClientItemBusiness.ClientItem client in clients)
                        {
                            clientList.Remove(client);
                            CallBackEvent.ClientDisconnect(client.gID);
                        }
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex);
                }

                Thread.Sleep(5000);
            }
        }