示例#1
0
        private void CheckNet_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            TimeSpan span = SuperFramework.SuperDate.DateHelper.DateDiff2(DateTime.Now, checkTime);

            if (span.TotalSeconds >= 60 * 2)
            {
                if (!isSendNetState)
                {
                    H3CConnection?.Invoke(powerIp, DateTime.Now, (H3CMsgType)Enum.Parse(typeof(H3CMsgType), "4"));
                    checkTime      = DateTime.Now;
                    isSendNetState = true;
                }
            }
        }
示例#2
0
 private void Client_OnStateInfo(string msg, SuperFramework.SuperSocket.TCP.TCPSyncSocketEnum.SocketState state)
 {
     try
     {
         ShowMsg(msg);
         if (state == SuperFramework.SuperSocket.TCP.TCPSyncSocketEnum.SocketState.Connected)
         {
             isSendData = true;
             if (connectStatusSend)
             {
                 H3CConnection?.Invoke(powerIp, DateTime.Now, (H3CMsgType)Enum.Parse(typeof(H3CMsgType), "0"));
                 (new Thread(new ThreadStart(HandleData))
                 {
                     IsBackground = true
                 }).Start();
                 connectStatusSend    = isSendNetState = false;
                 disconnectStatusSend = reconnectionStatusSend = true;
             }
             checkNet.Start();
         }
         else if (state == SuperFramework.SuperSocket.TCP.TCPSyncSocketEnum.SocketState.Disconnect)
         {
             if (disconnectStatusSend)
             {
                 H3CConnection?.Invoke(powerIp, DateTime.Now, (H3CMsgType)Enum.Parse(typeof(H3CMsgType), "6"));
                 connectStatusSend    = reconnectionStatusSend = true;
                 disconnectStatusSend = isSendNetState = false;
                 handleDataCount      = 0;
             }
             checkNet.Stop();
             isSendData = false;
         }
         else if (state == SuperFramework.SuperSocket.TCP.TCPSyncSocketEnum.SocketState.Reconnection)
         {
             if (reconnectionStatusSend)
             {
                 H3CConnection?.Invoke(powerIp, DateTime.Now, (H3CMsgType)Enum.Parse(typeof(H3CMsgType), "5"));
                 reconnectionStatusSend = isSendNetState = false;
                 connectStatusSend      = disconnectStatusSend = true;
                 handleDataCount        = 0;
             }
             checkNet.Stop();
             isSendData = false;
         }
     }
     catch (Exception) { }
 }