예제 #1
0
        protected override void Setup()
        {
            LogManager.SetLoggerFactory(Log4NetLoggerFactory.Instance);
            GlobalContext.Properties["LogFileName"] = ApplicationName;
            XmlConfigurator.ConfigureAndWatch(new FileInfo(Path.Combine(BinaryPath, "log4net.config")));

            var builder = new ContainerBuilder();

            Initialize(builder);

            var container = builder.Build();

            _factory             = container.Resolve <PhotonPeerFactory>();
            ConnectionCollection = container.Resolve <PhotonConnectionCollection>();
            _backgroundThreads   = container.Resolve <IEnumerable <IBackgroundThread> >();

            ResolveParameters(container);

            foreach (var backgroundthread in _backgroundThreads)
            {
                backgroundthread.Setup();
                ThreadPool.QueueUserWorkItem(backgroundthread.Run);
            }

            if (ConnectsToMaster)
            {
                ConnectToMaster();
            }
        }
예제 #2
0
        protected override void Setup()
        {
            LogManager.SetLoggerFactory(Log4NetLoggerFactory.Instance);
            Log = LogManager.GetCurrentClassLogger();
            GlobalContext.Properties["LogFileName"] = ApplicationName;
            XmlConfigurator.ConfigureAndWatch(new FileInfo(Path.Combine(BinaryPath, "log4net.config")));

            var config = new ConfigurationBuilder();

            config.AddXmlFile(Path.Combine(BinaryPath, ApplicationName + ".config"));
            // config.AddJsonFile(Path.Combine(BinaryPath, ApplicationName + ".json"));

            var module = new ConfigurationModule(config.Build());

            // Create the autofac container
            var builder = new ContainerBuilder();

            builder.RegisterInstance(this).SingleInstance();
            builder.RegisterInstance(Log).As <ILogger>().SingleInstance();
            builder.RegisterModule(module);

            var container = builder.Build();

            ServerApplication = container.Resolve <IServerApplication>();
            ServerApplication.Setup();
            PeerFactory = container.Resolve <IPeerFactory>();
        }
예제 #3
0
        /// <summary>
        /// 类型:方法
        /// 名称:Setup
        /// 作者:taixihuase
        /// 作用:启动并初始化客户端
        /// 编写日期:2015/7/12
        /// </summary>
        protected override void Setup()
        {
            // 创建日志
            GlobalContext.Properties["Photon:ApplicationLogPath"] = Path.Combine(ApplicationRootPath, "log");

            string path = Path.Combine(BinaryPath, "log4net.config");
            var    file = new FileInfo(path);

            if (file.Exists)
            {
                LogManager.SetLoggerFactory(Log4NetLoggerFactory.Instance);
                XmlConfigurator.ConfigureAndWatch(file);
            }

            Log.Debug(DateTime.Now + " : Server is running");

            // 初始化数据库操作列表
            Data = new DatabaseCollection(this);

            // 初始化用户列表
            Users = new UserCollection(this);

            // 初始化玩家角色列表
            Characters = new CharacterCollection(this);
        }
예제 #4
0
 /// <summary>
 /// 初始化日志
 /// </summary>
 private void InitLogging()
 {
     LogManager.SetLoggerFactory(Log4NetLoggerFactory.Instance);
     GlobalContext.Properties["Photon:ApplicationLogPath"] = Path.Combine(this.ApplicationRootPath, "log");
     GlobalContext.Properties["LogFileName"] = "MS" + this.ApplicationName;
     XmlConfigurator.ConfigureAndWatch(new FileInfo(Path.Combine(this.BinaryPath, "log4net.config")));
 }
        protected override void Setup()
        {
            //初始化Game Server

            LogManager.SetLoggerFactory(Log4NetLoggerFactory.Instance);
            GlobalContext.Properties["LogFileName"] = ApplicationName + System.DateTime.Now.ToString("yyyy-MM-dd");
            XmlConfigurator.ConfigureAndWatch(new FileInfo(Path.Combine(BinaryPath, "log4net.config")));
        }
예제 #6
0
        protected override void Setup()
        {
            LogManager.SetLoggerFactory(Log4NetLoggerFactory.Instance);
            GlobalContext.Properties["Photon:ApplicationLogPath"] = Path.Combine(this.ApplicationRootPath, "log");
            GlobalContext.Properties["LogFileName"] = "MS_" + this.ApplicationName;
            XmlConfigurator.ConfigureAndWatch(new FileInfo(Path.Combine(this.BinaryPath, "log4net.config")));

            log.Debug("GameServer is runing");
        }
예제 #7
0
        /// <summary>
        ///     配置日志文件
        /// </summary>
        private void SetupLog()
        {
            GlobalContext.Properties["Photon:ApplicationLogPath"] = Path.Combine(Path.Combine(ApplicationRootPath, "bin_Win64"), "log"); //设置日志目录
            var path = Path.Combine(BinaryPath, "log4net.config");
            var file = new FileInfo(path);

            LogManager.SetLoggerFactory(Log4NetLoggerFactory.Instance);
            XmlConfigurator.ConfigureAndWatch(file);
            Log.Info("日志配置文件设置成功");
        }
        protected override void Setup()
        {
            LogManager.SetLoggerFactory(Log4NetLoggerFactory.Instance);
            GlobalContext.Properties["Photon:ApplicationLogPath"] = Path.Combine(this.ApplicationRootPath, "log");
            GlobalContext.Properties["LogFileName"] = "MS" + this.ApplicationName;
            XmlConfigurator.ConfigureAndWatch(new FileInfo(Path.Combine(this.BinaryPath, "log4net.config")));

            Protocol.AllowRawCustomValues = true;
            this.SetUnmanagedDllDirectory();
            this.Initialize();
        }
예제 #9
0
 /// <summary>
 /// 初始化日志
 /// </summary>
 private void InitLog()
 {
     // 指定使用的log插件
     LogManager.SetLoggerFactory(Log4NetLoggerFactory.Instance);
     // 指定日志文件存放位置
     GlobalContext.Properties["Photon:ApplicationLogPath"] = Path.Combine(
         Path.Combine(this.ApplicationRootPath, "bin_Win64"), "log");
     // 指定日志名称
     GlobalContext.Properties["LogFileName"] = this.ApplicationName;
     // 读取配置文件
     XmlConfigurator.ConfigureAndWatch(new FileInfo(Path.Combine(this.BinaryPath, "log4net.config")));
 }
예제 #10
0
        private void InitLog4Net()
        {
            GlobalContext.Properties["Photon:ApplicationLogPath"] =
                Path.Combine(ApplicationRootPath, "bin_Win64", "log"); //设置属性{Photon:ApplicationLogPath}
            FileInfo configFileInfo = new FileInfo(Path.Combine(BinaryPath, "log4net.config"));

            if (configFileInfo.Exists)
            {
                LogManager.SetLoggerFactory(Log4NetLoggerFactory.Instance); //Log工厂设置插件
                XmlConfigurator.ConfigureAndWatch(configFileInfo);          //读取xml配置文件
            }
        }
예제 #11
0
        private static void Setup()
        {
            LogManager.SetLoggerFactory(ExitGames.Logging.Log4Net.Log4NetLoggerFactory.Instance);
            Console.WriteLine(AppDomain.CurrentDomain.BaseDirectory);

            var configFileInfo = new FileInfo(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "log4net.config"));

            XmlConfigurator.ConfigureAndWatch(configFileInfo);

            AppDomain.CurrentDomain.UnhandledException += OnUnhandledException;

            //WindowsCounters.Initialize();
        }
예제 #12
0
        //初始化日志
        void IniLog()
        {
            //日志配置文件初始化
            GlobalContext.Properties["Photon:ApplicationLogPath"] = Path.Combine(ApplicationRootPath, "bin_Win64", "log"); //日志存储路径
            GlobalContext.Properties["LogFileName"] = "My Game";                                                           //日志名字

            FileInfo configFileInfo = new FileInfo(Path.Combine(BinaryPath, "log4net.config"));                            //读取文件

            if (configFileInfo.Exists)
            {
                LogManager.SetLoggerFactory(Log4NetLoggerFactory.Instance); //指定log4net日志插件
                XmlConfigurator.ConfigureAndWatch(configFileInfo);          //log4net读取配置文件
            }
        }
예제 #13
0
        //服务器启动时调用
        protected override void Setup()
        {
            LogManager.SetLoggerFactory(Log4NetLoggerFactory.Instance);
            GlobalContext.Properties["Photon:ApplicationLogPath"] = Path.Combine(ApplicationRootPath, "log");
            GlobalContext.Properties["LogFileName"] = "MySer_" + ApplicationName;
            XmlConfigurator.ConfigureAndWatch(new FileInfo(Path.Combine(BinaryPath, "log4net.config")));

            log.Info("MyGameServer start----------");


            Instance = this;
            InitHandler();
            syncPosThread.Run();
        }
예제 #14
0
        protected override void Setup()
        {
            LogManager.SetLoggerFactory(Log4NetLoggerFactory.Instance);
            GlobalContext.Properties["LogFileName"] = ApplicationName + System.DateTime.Now.ToString("yyyy-MM-dd");
            XmlConfigurator.ConfigureAndWatch(new FileInfo(Path.Combine(BinaryPath, "log4net.config")));
            Logger = LogManager.GetLogger(this.GetType().FullName);

            Logger.Info("Setup begin.");
            _Framework = _Setup();
            _Framework.Launch();
            _FrameworkThread          = new System.Threading.Thread(_FrameworkUpdate);
            _FrameworkThread.Priority = System.Threading.ThreadPriority.Normal;
            _FrameworkThread.Start();

            Logger.Info("Setup end.");
        }
예제 #15
0
        protected override void Setup()
        {
            try {
                LogManager.SetLoggerFactory(Log4NetLoggerFactory.Instance);
                GlobalContext.Properties["Photon:ApplicationLogPath"] = Path.Combine(this.ApplicationRootPath, "log");
                GlobalContext.Properties["LogFileName"] = "MS" + this.ApplicationName;
                XmlConfigurator.ConfigureAndWatch(new FileInfo(Path.Combine(this.BinaryPath, "log4net.config")));

                Protocol.AllowRawCustomValues = true;
                this.MasterNodeId             = (byte)MasterServerSettings.Default.MasterNodeId;

                this.Initialize();
            } catch (Exception ex) {
                log.Error(ex);
                log.Error(ex.StackTrace);
            }
        }
예제 #16
0
        protected override void Setup()
        {
            //server init
            LogManager.SetLoggerFactory(Log4NetLoggerFactory.Instance);
            GlobalContext.Properties["LogFileName"] = this.ApplicationName + System.DateTime.Now.ToString("yyyy-MM-dd-hh-mm");
            XmlConfigurator.ConfigureAndWatch(new FileInfo(Path.Combine(BinaryPath, "log4net.config")));

            Log.Debug("!!! STPhotonServer Start !!!");

            lconnected_peer = new List <PeerBase>();
            game_app        = new STGameApp(lconnected_peer);


            //Timer timer=new Timer(2000);
            //timer.Elapsed+=new ElapsedEventHandler(sendToAll);
            //timer.AutoReset=true;
            //timer.Enabled=true;
        }
예제 #17
0
        protected override void Setup()
        {
            GlobalContext.Properties["Photon:ApplicationLogPath"] = Path.Combine(ApplicationRootPath, "log");

            // log4net
            var path = Path.Combine(BinaryPath, "log4net.config");
            var file = new FileInfo(path);

            if (file.Exists)
            {
                LogManager.SetLoggerFactory(Log4NetLoggerFactory.Instance);
                XmlConfigurator.ConfigureAndWatch(file);
            }

            Log.InfoFormat("Created application Instance: type={0}", Instance.GetType());

            Initialize();
        }
예제 #18
0
        public void Setup(MarsApplication loginApplication)
        {
            LogManager.SetLoggerFactory(Log4NetLoggerFactory.Instance);
            GlobalContext.Properties["LogFileName"] = loginApplication.ApplicationName + System.DateTime.Now.ToString("yyyy-MM-dd");
            XmlConfigurator.ConfigureAndWatch(new FileInfo(Path.Combine(loginApplication.BinaryPath, "log4net.config")));
            // 初始化GameServer

            log4net.GlobalContext.Properties["Photon:ApplicationLogPath"] = Path.Combine(loginApplication.ApplicationRootPath, "log");

            // log4net
            string path = Path.Combine(loginApplication.BinaryPath, "log4net.config");
            var    file = new FileInfo(path);

            if (file.Exists)
            {
                LogManager.SetLoggerFactory(Log4NetLoggerFactory.Instance);
                XmlConfigurator.ConfigureAndWatch(file);
            }
        }
예제 #19
0
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        /// <param name="args">
        /// The args.
        /// </param>
        private static void Main(params string[] args)
        {
            LogManager.SetLoggerFactory(ExitGames.Logging.Log4Net.Log4NetLoggerFactory.Instance);
            Console.WriteLine(AppDomain.CurrentDomain.BaseDirectory);

            // Set logfile name and application name variables
            FileInfo configFileInfo;

            try
            {
                // IOException if another process already writes to the file
                if (File.Exists(@"log\" + firstGameName + ".log"))
                {
                    File.Delete(@"log\" + firstGameName + ".log");
                }

                GlobalContext.Properties["LogName"] = firstGameName + ".log";

                configFileInfo = new FileInfo(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "log4net.config"));
            }
            catch (IOException)
            {
                GlobalContext.Properties["LogName"] = baseGameName + ".log";

                // just write to console for now
                configFileInfo = new FileInfo(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "log4netConsole.config"));
            }

            XmlConfigurator.ConfigureAndWatch(configFileInfo);

            AppDomain.CurrentDomain.UnhandledException += OnUnhandledException;

            WindowsCounters.Initialize();

            int index = 0;

            if (args.Length > index)
            {
                Settings.TestCase = args[index];
            }

            index++;
            if (args.Length > index)
            {
                Settings.NumGames = byte.Parse(args[index]);
            }

            index++;
            if (args.Length > index)
            {
                Settings.NumClientsPerGame = byte.Parse(args[index]);
            }

            index++;
            if (args.Length > index)
            {
                Settings.ServerAddress = args[index];
            }

            index++;
            if (args.Length > index)
            {
                Settings.FlushInterval = int.Parse(args[index]);
            }

            index++;
            if (args.Length > index)
            {
                Settings.SendReliableData = bool.Parse(args[index]);
            }

            index++;
            if (args.Length > index)
            {
                Settings.ReliableDataSendInterval = int.Parse(args[index]);
            }

            index++;
            if (args.Length > index)
            {
                Settings.SendUnreliableData = bool.Parse(args[index]);
            }

            index++;
            if (args.Length > index)
            {
                Settings.UnreliableDataSendInterval = int.Parse(args[index]);
            }

            Console.WriteLine("Test case: " + Settings.TestCase);
            Console.WriteLine("Settings: {0} games per process, {1} players per game, game server at {2}",
                              Settings.NumGames,
                              Settings.NumClientsPerGame,
                              Settings.ServerAddress);

            if (Settings.SendReliableData)
            {
                Console.WriteLine("Sending reliable operation every {0} ms", Settings.ReliableDataSendInterval);
            }

            if (Settings.SendUnreliableData)
            {
                Console.WriteLine("Sending unreliable operation every {0} ms", Settings.UnreliableDataSendInterval);
            }

            Console.WriteLine();

            stopped = false;
            fiber.Start();
            counterLoggingFiber.Start();

            counterLoggingFiber.ScheduleOnInterval(PrintCounter, Settings.LogCounterInterval, Settings.LogCounterInterval);

            try
            {
                log.InfoFormat("Starting {0} games with {1} players", Settings.NumGames, Settings.NumClientsPerGame);
                for (int g = 0; g < Settings.NumGames; g++)
                {
                    fiber.Enqueue(StartGame);
                }

                ////log.InfoFormat("{0} clients running", clients.Count);
                Console.WriteLine("[{0}] Press Return to End", Process.GetCurrentProcess().Id);
                Console.ReadLine();

                ////log.InfoFormat("Stopping {0} clients", clients.Count);
                StopGames();
                fiber.Stop();

                // wait for stop to complete
                resetEvent.WaitOne();
            }
            catch (Exception e)
            {
                log.Error(e);
            }
            finally
            {
                log.InfoFormat("[{0}] Stopped", Process.GetCurrentProcess().Id);
            }
        }
예제 #20
0
 protected virtual void InitLogging()
 {
     LogManager.SetLoggerFactory(Log4NetLoggerFactory.Instance);
     GlobalContext.Properties["LogFileName"] = "SS" + ApplicationName;
     XmlConfigurator.ConfigureAndWatch(new FileInfo(Path.Combine(BinaryPath, "log4net.config")));
 }