public static void UpdateServerProperties() { List <BattleServer> servers = BattleMgr.GetAllBattles(); foreach (BattleServer server in servers) { server.UpdateServerProperties(); } }
public static BattleServer AddRoom(BaseRoom room) { BattleServer battleServer = BattleMgr.FindActiveServer(); if (battleServer != null && battleServer.AddRoom(room)) { return(battleServer); } return(null); }
public static void Disconnet(int id) { BattleServer server = BattleMgr.GetServer(id); if (server != null && server.IsActive) { server.LastRetryTime = DateTime.Now; server.RetryCount = BattleMgr.MAX_RECONNECT_TIME; server.Stop(); } }
public static BattleServer AddRoom(BaseRoom room) { BattleServer server = BattleMgr.FindActiveServer(room); BattleServer result; if (server != null && server.AddRoom(room)) { result = server; } else { result = null; } return(result); }
public static bool Setup(GameServerConfig config) { BattleMgr.m_list.Clear(); if (File.Exists("battle.xml")) { try { BattleMgr.AddBattleServer(new BattleServer(1, config.FightIP, config.FightPort, config.FightKey, true, false)); if (config.IsOpenCrossFight) { BattleMgr.AddBattleServer(new BattleServer(2, config.CrossFightIP, config.CrossFightPort, config.CrossFightKey, true, true)); IsOpenAreaFight = true; } } catch (Exception ex) { BattleMgr.log.Error("BattleMgr setup error:", ex); } } BattleMgr.log.InfoFormat("BattlMgr:total {0} battle server loaded.", BattleMgr.m_list.Count); return(true); }
private static void battle_Disconnected(object sender, EventArgs e) { BattleServer server = sender as BattleServer; BattleMgr.log.ErrorFormat("Disconnect from battle server {0}:{1}", server.Ip, server.Port); if (server != null && BattleMgr.AutoReconnect && BattleMgr.m_list.Contains(server)) { BattleMgr.RemoveServer(server); if ((DateTime.Now - server.LastRetryTime).TotalMinutes > (double)BattleMgr.MAX_RECOUNT_MINS) { server.RetryCount = 0; } if (server.RetryCount < BattleMgr.MAX_RECONNECT_TIME) { BattleServer newserver = server.Clone(); BattleMgr.AddBattleServer(newserver); newserver.RetryCount = server.RetryCount + 1; newserver.LastRetryTime = DateTime.Now; newserver.Start(); } } }
public static BattleServer FindActiveServer(BaseRoom room) { int type = 0; return(BattleMgr.FindFightServerByType(type, room.IsArea)); }