private void checkNet_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { TimeSpan span = SuperFramework.SuperDate.DateHelper.DateDiff2(DateTime.Now, checkTime); if (span.TotalSeconds >= 120) { DSSystemConnection?.Invoke(DateTime.Now, deviceIp, (DSConnectionState)Enum.Parse(typeof(DSConnectionState), "5")); 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) { checkNet.Start(); isSendData = true; if (connectStatusSend) { (new Thread(new ThreadStart(GetData)) { IsBackground = true }).Start(); DSSystemConnection?.Invoke(DateTime.Now, deviceIp, (DSConnectionState)Enum.Parse(typeof(DSConnectionState), "0")); connectStatusSend = false; disconnectStatusSend = reconnectionStatusSend = true; } } else if (state == SuperFramework.SuperSocket.TCP.TCPSyncSocketEnum.SocketState.Disconnect) { checkNet.Stop(); isSendData = false; if (disconnectStatusSend) { DSSystemConnection?.Invoke(DateTime.Now, deviceIp, (DSConnectionState)Enum.Parse(typeof(DSConnectionState), "1")); connectStatusSend = reconnectionStatusSend = true; disconnectStatusSend = false; } } else if (state == SuperFramework.SuperSocket.TCP.TCPSyncSocketEnum.SocketState.Reconnection) { checkNet.Stop(); isSendData = false; if (reconnectionStatusSend) { DSSystemConnection?.Invoke(DateTime.Now, deviceIp, (DSConnectionState)Enum.Parse(typeof(DSConnectionState), "2")); reconnectionStatusSend = false; connectStatusSend = disconnectStatusSend = true; } } } catch (Exception) { } }