Пример #1
0
        /// <summary>
        /// Load Invalid Names Patterns from File
        /// </summary>
        public void LoadInvalidNamesFromFile()
        {
            if (string.IsNullOrEmpty(InvalidNamesFile))
            {
                if (log.IsErrorEnabled)
                {
                    log.Error("Invalid Names File Configuration is null, not loading restriction...");
                }

                return;
            }

            if (!File.Exists(InvalidNamesFile))
            {
                if (log.IsWarnEnabled)
                {
                    log.WarnFormat("Invalid Names File does not exists, trying to create default file: {0}", InvalidNamesFile);
                }

                try
                {
                    ResourceUtil.ExtractResource("invalidnames.txt", InvalidNamesFile);
                }
                catch (Exception ex)
                {
                    if (log.IsErrorEnabled)
                    {
                        log.Error("Default Invalid Names File could not be created, not loading restriction...", ex);
                    }

                    return;
                }
            }

            try
            {
                using (StreamReader file = File.OpenText(InvalidNamesFile))
                {
                    var    lines = new List <string>();
                    string line  = null;

                    while ((line = file.ReadLine()) != null)
                    {
                        lines.Add(line);
                    }

                    LoadFromLines(lines);

                    file.Close();
                }
            }
            catch (Exception ex)
            {
                if (log.IsErrorEnabled)
                {
                    log.ErrorFormat("Error while loading Invalid Names File ({0}):\n{1}", InvalidNamesFile, ex);
                }
            }
        }
Пример #2
0
        static void Main(string[] args)
        {
            ResourceUtil.ExtractResource("LogConfig.xml", "LogConfig.xml", Assembly.GetAssembly(typeof(Program)));

            ByteSocket bs = new ByteSocket();

            bs.ConnectSuccessHandler += new ByteSocket.ConnectSocketDelegate(bs_ConnectSuccessHandler);

            bs.Connect("192.168.16.119", 20000);

            Console.ReadKey();
        }
Пример #3
0
        static void Main(string[] args)
        {
            ResourceUtil.ExtractResource("LogConfig.xml", "LogConfig.xml", Assembly.GetAssembly(typeof(Program)));
            //ResourceUtil.ExtractResourceSafe("LogConfig.xml", "LogConfig.xml", Assembly.GetAssembly(typeof(Program)));

            //ResourceUtil.ExtractResource("server.config", "server.config", Assembly.GetAssembly(typeof(Program)));
            //ResourceUtil.ExtractResourceSafe("server.config", "server.config", Assembly.GetAssembly(typeof(Program)));
            //GSConfigMgr.LoadGameServerConfig("server.config");

            GameServerMgr.DisabledCloseBtn();

            CommandMgr.Instance.SearchCommand(Assembly.GetAssembly(typeof(GSServer)));

            Console.WriteLine("指令系统初始化成功!!!\r\n");

            if (!CommandMgr.Instance.ExecuteCommand("LoadGameConfig"))
            {
                GameServerMgr.PressKeyExit();
                return;
            }

            if (!CommandMgr.Instance.ExecuteCommand("AllocBuffer"))
            {
                GameServerMgr.PressKeyExit();
                return;
            }

            if (!CommandMgr.Instance.ExecuteCommand("SetupPackageHandler"))
            {
                GameServerMgr.PressKeyExit();
                return;
            }

            if (!CommandMgr.Instance.ExecuteCommand("ListenLocal"))
            {
                GameServerMgr.PressKeyExit();
                return;
            }

            GameServerMgr.ConnectCenterServer();

            FightServerMgr.ConnectFightServers();

            GameServerMgr.Success();

            Console.WriteLine("游戏服务器启动成功!!!\r\n");

            GameServerMgr.WaitingInputCmd("GameServer");
        }
Пример #4
0
        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);
        }
Пример #5
0
        public static void CreateInstance(CenterServerConfig config)
        {
            //Only one intance
            if (Instance != null)
            {
                return;
            }

            FileInfo logConfig = new FileInfo(config.LogConfigFile);

            if (!logConfig.Exists)
            {
                ResourceUtil.ExtractResource(logConfig.Name, logConfig.FullName, Assembly.GetAssembly(typeof(CenterServer)));
            }
            //Configure and watch the config file
            XmlConfigurator.ConfigureAndWatch(logConfig);
            //Create the instance
            _instance = new CenterServer(config);
        }
Пример #6
0
        public static void CreateInstance(GameServerConfig 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(GameServer)));
            }

            //设置日志的配置
            XmlConfigurator.ConfigureAndWatch(logConfig);

            m_instance = new GameServer(config);
        }