private void updateServer(ClientControl clControl) { if (clControl != null) { LogUtil.Debug("启动心跳检测"); while (enable) { if (clControl.IsConnected()) { serverHeart.activeTime = DateTime.Now; if ((int)serverHeart.getTimeinterval() >= lossTime) { serverHeart.lostCount++; LogUtil.DebugFormat("服务端 [{0}] 丢包次数:{1} 尝试重新连接", serverHeart.ipEndPoint, serverHeart.lostCount); clControl.connect(); } if (serverHeart.lostCount >= lostCount) { clControl.removeServer(); LogUtil.InfoFormat("服务器 [{0}] 已断开!!", serverHeart.ipEndPoint); if (clControl.msgCallback != null) { clControl.msgCallback(string.Format("服务器 [{0}] 已断开!!", serverHeart.ipEndPoint)); } } } else { clControl.connect(); } clControl.SendToServer(OrderCode.HeartBeat); Thread.Sleep(waitTime); } } }