private static bool delegeteremoveallouttimeservers(Friend.SERVER server) { try { return(string.IsNullOrEmpty(server.ID)); } catch { return(false); } }
/// <summary> /// 处理要发送的消息线程 /// </summary> private static void THREADSENDMSG() { while (serverHelper.Iflag == 0) { try { if (_poolFactory.SendmsgINFO.Count > 0) { for (int i = 0; i < _poolFactory.SendmsgINFO.Count; i++) { try { if (_poolFactory.SendmsgINFO[i].Sendto == null || _poolFactory.SendmsgINFO[i].Sendto.Length == 0) { continue; } foreach (string sendto in _poolFactory.SendmsgINFO[i].Sendto) { Friend.Friend friend = _poolFactory.findFriend(sendto); if (!string.IsNullOrEmpty(sendto) && sendto.Contains("."))//IP用户 { if (_poolFactory.SendmsgINFO[i].IsNET) { if (serverHelper.islevelserver) { sendMsg(_poolFactory.SendmsgINFO[i].LantalkMsg, serverHelper.mainserveraddr, serverHelper.mainserverport); lastconnecttoserver = DateTime.Now; } else { if (friend != null && !string.IsNullOrEmpty(friend.ServerID))//如果此用户为次级服务器的用户 { Friend.SERVER erver = _poolFactory.findServerByID(friend.ServerID); if (erver != null) { ServersendMsg(_poolFactory.SendmsgINFO[i].LantalkMsg, erver.ADDR, erver.PORT); continue; } } ServersendMsg(_poolFactory.SendmsgINFO[i].LantalkMsg, sendto, _poolFactory.SendmsgINFO[i].SendPort); } } else { if (serverHelper.islevelserver && friend != null && friend.IsNet) { sendMsg(_poolFactory.SendmsgINFO[i].LantalkMsg, serverHelper.mainserveraddr, serverHelper.mainserverport); continue; } sendMsg(_poolFactory.SendmsgINFO[i].LantalkMsg, sendto); } } else if (!string.IsNullOrEmpty(sendto))//ID用户 { if (friend != null) { if (serverHelper.islevelserver && serverHelper.isloginedlevelserver) { sendMsg(_poolFactory.SendmsgINFO[i].LantalkMsg, serverHelper.mainserveraddr, serverHelper.mainserverport); lastconnecttoserver = DateTime.Now; } else { ServersendMsg(_poolFactory.SendmsgINFO[i].LantalkMsg, serverHelper.getIP(friend.Ip), friend.Port); } } } Thread.Sleep(20); } } catch (Exception ex) { serverHelper.writeLog("发送消息时出错" + ex.Message); } finally { _poolFactory.SendmsgINFO[i].Sendto = null; } } _poolFactory.clearSendMsgInfo();//清除已发送的消息 } else { if (serverHelper.islevelserver && lastconnecttoserver < DateTime.Now.AddSeconds(-30)) { sendMsg(sayHelloToServer(), serverHelper.mainserveraddr, serverHelper.mainserverport); lastconnecttoserver = DateTime.Now; } Thread.Sleep(20); } } catch (Exception ex) { serverHelper.writeLog("msghelper.THREADSENDMSG " + ex.Message); _poolFactory.clearSendMsgInfo();//清除已发送的消息 } } }
private static bool delegtefindserverbyaddrandport(Friend.SERVER server) { return(server.ADDR.Equals(_curServerADDR) && server.PORT.Equals(_curServerPort)); }
private static bool delegtefindserverbyaddr(Friend.SERVER server) { return(server.ADDR.Equals(_curServerIP)); }
private static bool delegtefindserverbyid(Friend.SERVER server) { return(server.ID.Equals(_curServerID)); }