/// <summary> /// 移除超时的节点 /// </summary> public static void RemoveOutLimited() { for (int i = 0; i < ArrCients.Count; i++) { client_obj temp = (client_obj)ArrCients[i]; if (temp.LinkCount > 8) { ArrCients.Remove(temp); RemoveOutLimited(); } } }
/// <summary> /// 设置服务器端的消息 /// </summary> public void SetSeverMessages(string recvStr) { client_obj clobj = new client_obj(); clobj.Ip = recvStr.Split(';')[0].ToString(); clobj.UserName = recvStr.Split(';')[1].ToString(); clobj.ZhiWu = recvStr.Split(';')[2].ToString(); clobj.ZhiCheng = recvStr.Split(';')[3].ToString(); clobj.Account_Name = recvStr.Split(';')[4].ToString(); clobj.LinkCount = 0; if (!IsHaveSame(clobj)) { ArrCients.Add(clobj); } }
/// <summary> /// 获取服务器端的消息 /// </summary> public string GetSeverMessages() { string tempstr = ""; for (int i = 0; i < ArrCients.Count; i++) { client_obj tb = (client_obj)ArrCients[i]; string strval = tb.Ip + " " + tb.UserName + " " + tb.ZhiWu + " " + tb.ZhiCheng + " " + tb.Account_Name; if (tempstr.Trim() == "") { tempstr = strval; } else { tempstr = tempstr + "\n" + strval; } } return(tempstr); }
/// <summary> /// 相同匹配操作 /// </summary> /// <param name="clobj"></param> /// <returns></returns> public static bool IsHaveSame(client_obj clobj) { bool flag = false; for (int i = 0; i < ArrCients.Count; i++) { client_obj temp = (client_obj)ArrCients[i]; if (clobj.Ip == temp.Ip && clobj.UserName == temp.UserName && clobj.ZhiWu == temp.ZhiWu && clobj.ZhiCheng == temp.ZhiCheng && clobj.Account_Name == temp.Account_Name) { temp.LinkCount = 0; ArrCients[i] = temp; flag = true; } } return(flag); }