public static void CreateInstance(FightServerConfig config) { if (FightServer.m_instance != null) { return; } FileInfo fileInfo = new FileInfo(config.LogConfigFile); if (!fileInfo.Exists) { ResourceUtil.ExtractResource(fileInfo.Name, fileInfo.FullName, Assembly.GetAssembly(typeof(FightServer))); } XmlConfigurator.ConfigureAndWatch(fileInfo); FightServer.m_instance = new FightServer(config); }
public static void CreateInstance(FightServerConfig config) { //Only one intance if (m_instance != null) return; FileInfo logConfig = new FileInfo(config.LogConfigFile); if (!logConfig.Exists) { ResourceUtil.ExtractResource(logConfig.Name, logConfig.FullName, Assembly.GetAssembly(typeof(FightServer))); } //Configure and watch the config file XmlConfigurator.ConfigureAndWatch(logConfig); //Create the instance m_instance = new FightServer(config); }
public static void CreateInstance(FightServerConfig config) { //Only one intance if (m_instance != null) { return; } FileInfo logConfig = new FileInfo(config.LogConfigFile); if (!logConfig.Exists) { ResourceUtil.ExtractResource(logConfig.Name, logConfig.FullName, Assembly.GetAssembly(typeof(FightServer))); } //Configure and watch the config file XmlConfigurator.ConfigureAndWatch(logConfig); //Create the instance m_instance = new FightServer(config); }
/// <summary> /// 构造函数 /// </summary> /// <param name="config"></param> private FightServer(FightServerConfig config) { m_config = config; }
/// <summary> /// Handles the server action /// </summary> /// <param name="parameters"></param> public void OnAction(Hashtable parameters) { Console.WriteLine("Starting FightingServer ... please wait a moment!"); FightServerConfig config = new FightServerConfig(); try { config.Load(); } catch (Exception ex) { Console.WriteLine(ex.Message); Console.ReadKey(); return; } FightServer.CreateInstance(config); FightServer.Instance.Start(); bool run = true; while (run) { try { Console.Write("> "); string line = Console.ReadLine(); string[] para = line.Split(' '); switch (para[0].ToLower()) { case "clear": Console.Clear(); break; case "list": if (para.Length > 1) { switch (para[1]) { case "-client": Console.WriteLine("server client list:"); Console.WriteLine("--------------------"); ServerClient[] list = FightServer.Instance.GetAllClients(); foreach (ServerClient client in list) { Console.WriteLine(client.ToString()); } Console.WriteLine("-------------------"); break; case "-room": Console.WriteLine("room list:"); Console.WriteLine("-------------------------------"); ProxyRoom[] rooms = ProxyRoomMgr.GetAllRoom(); foreach (ProxyRoom room in rooms) { Console.WriteLine(room.ToString()); } Console.WriteLine("-------------------------------"); break; case "-game": Console.WriteLine("game list:"); Console.WriteLine("-------------------------------"); List<BaseGame> games = GameMgr.GetGames(); foreach (BaseGame g in games) { Console.WriteLine(g.ToString()); } Console.WriteLine("-------------------------------"); break; } } else { Console.WriteLine("list [-client][-room][-game]"); Console.WriteLine(" -client:列出所有服务器对象"); Console.WriteLine(" -room:列出所有房间对象"); Console.WriteLine(" -game:列出所有游戏对象"); } break; case "exit": run = false; break; default: break; } } catch (Exception ex) { Console.WriteLine("Error:" + ex.ToString()); } } if (FightServer.Instance != null) FightServer.Instance.Stop(); }