Esempio n. 1
0
 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);
 }
Esempio n. 2
0
        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();
                }
            }
        }