/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void checkNet_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { TimeSpan span = SuperFramework.SuperDate.DateHelper.DateDiff2(DateTime.Now, checkTime); if (span.TotalSeconds >= 30) { CHDConnection?.Invoke(DateTime.Now, (CHDMsgType)Enum.Parse(typeof(CHDMsgType), "8")); checkTime = DateTime.Now; } }
private void Client_OnStateInfo(string msg, SuperFramework.SuperSocket.TCP.TCPSyncSocketEnum.SocketState state) { try { ShowMsg(msg); if (state == SuperFramework.SuperSocket.TCP.TCPSyncSocketEnum.SocketState.Connected) { if (connectStatusSend) { CHDConnection?.Invoke(DateTime.Now, (CHDMsgType)Enum.Parse(typeof(CHDMsgType), "0")); connectStatusSend = false; disconnectStatusSend = reconnectionStatusSend = true; } checkNet.Start(); } else if (state == SuperFramework.SuperSocket.TCP.TCPSyncSocketEnum.SocketState.Disconnect) { checkNet.Stop(); if (disconnectStatusSend) { CHDConnection?.Invoke(DateTime.Now, (CHDMsgType)Enum.Parse(typeof(CHDMsgType), "6")); connectStatusSend = reconnectionStatusSend = true; disconnectStatusSend = false; } } else if (state == SuperFramework.SuperSocket.TCP.TCPSyncSocketEnum.SocketState.Reconnection) { checkNet.Stop(); if (reconnectionStatusSend) { CHDConnection?.Invoke(DateTime.Now, (CHDMsgType)Enum.Parse(typeof(CHDMsgType), "5")); reconnectionStatusSend = false; connectStatusSend = disconnectStatusSend = true; } } } catch (Exception) { } }