Exemplo n.º 1
0
 protected override void OnStartAffer()
 {
     try
     {
         var setting = new EnvironmentSetting();
         setting.EntityAssembly = Assembly.Load("GameRanking.Model");
         ScriptEngines.AddReferencedAssembly("GameRanking.Model.dll");
         ActionFactory.SetActionIgnoreAuthorize(1000, 1001);
         var cacheSetting = new CacheSetting();
         cacheSetting.ChangedHandle += OnChangedNotify;
         GameEnvironment.Start(setting, cacheSetting);
         var       cache = new ShareCacheStruct <UserRanking>();
         Stopwatch t     = new Stopwatch();
         t.Start();
         var list = cache.FindAll(false);
         t.Stop();
         if (list.Count > 0)
         {
         }
         Console.WriteLine("The server is staring...");
     }
     catch (Exception ex)
     {
         TraceLog.WriteError("App star error:{0}", ex);
     }
 }
Exemplo n.º 2
0
        protected override void OnStartAffer()
        {
            try
            {
                var setting = new EnvironmentSetting();
                setting.ClientDesDeKey = "j6=9=1ac";
                setting.EntityAssembly = Assembly.Load("ZyGames.Doudizhu.Model");
                GameEnvironment.Start(setting);

                ScriptEngines.AddReferencedAssembly(new string[] {
                    "ZyGames.Doudizhu.Lang.dll",
                    "ZyGames.Doudizhu.Model.dll",
                    "ZyGames.Doudizhu.Bll.dll"
                });
                ActionFactory.SetActionIgnoreAuthorize(1012, 9001, 9203);

                AppstoreClientManager.Current.InitConfig();
                LoadUnlineUser();
                InitRanking();
            }
            catch (Exception ex)
            {
                TraceLog.WriteError("OnStartAffer error:{0}", ex);
            }
        }
Exemplo n.º 3
0
        protected void Application_Start(object sender, EventArgs e)
        {
            try
            {
                var setting = new EnvironmentSetting();
                setting.ClientDesDeKey = "j6=9=1ac";
                setting.EntityAssembly = Assembly.Load("ZyGames.Tianjiexing.Model");
                ScriptEngines.AddReferencedAssembly(new string[] {
                    "ZyGames.Tianjiexing.Lang.dll",
                    "ZyGames.Tianjiexing.Model.dll",
                    "ZyGames.Tianjiexing.Component.dll",
                    "ZyGames.Tianjiexing.BLL.Combat.dll",
                    "ZyGames.Tianjiexing.BLL.GM.dll",
                    "ZyGames.Tianjiexing.BLL.dll"
                });
                GameEnvironment.Start(setting);

                SystemGlobal.Run();

#if (DEBUG)
                TraceLog.WriteError("系统正使用Debug版本");
#else
                TraceLog.ReleaseWrite("系统正使用Release版本");
#endif
            }
            catch (Exception ex)
            {
                TraceLog.WriteError("global start error:{0}", ex);
            }
        }
        /// <summary>
        /// The game service start.
        /// </summary>
        /// <param name="setting">Environment setting.</param>
        /// <param name="cacheSetting">Cache setting.</param>
        public static void Start(EnvironmentSetting setting, CacheSetting cacheSetting)
        {
            if (IsRunning)
            {
                return;
            }

            TraceLog.WriteLine("{0} Server is starting...", DateTime.Now.ToString("HH:mm:ss"));
            _setting = setting;
            if (!RedisConnectionPool.Ping("127.0.0.1"))
            {
                string error = string.Format("Error: NIC is not connected or no network.");
                TraceLog.WriteLine(error);
                TraceLog.WriteError(error);
                return;
            }
            RedisConnectionPool.Initialize(_setting.Serializer);
            if (!RedisConnectionPool.CheckConnect())
            {
                string error = string.Format("Error: the redis server is not started.");
                TraceLog.WriteLine(error);
                TraceLog.WriteError(error);
                return;
            }
            TraceLog.WriteLine("{0} Redis server connect successfully.", DateTime.Now.ToString("HH:mm:ss"));

            DbConnectionProvider.Initialize();
            TraceLog.WriteLine("{0} DB server connect successfully.", DateTime.Now.ToString("HH:mm:ss"));

            EntitySchemaSet.CacheGlobalPeriod = _setting.CacheGlobalPeriod;
            EntitySchemaSet.CacheUserPeriod   = _setting.CacheUserPeriod;
            if (_setting.EntityAssembly != null)
            {
                ProtoBufUtils.LoadProtobufType(_setting.EntityAssembly);
                EntitySchemaSet.LoadAssembly(_setting.EntityAssembly);
            }

            ZyGameBaseConfigManager.Intialize();
            //init script.
            if (_setting.ScriptSysAsmReferences.Length > 0)
            {
                ScriptEngines.AddSysReferencedAssembly(_setting.ScriptSysAsmReferences);
            }
            ScriptEngines.AddReferencedAssembly("ZyGames.Framework.Game.dll");
            if (_setting.ScriptAsmReferences.Length > 0)
            {
                ScriptEngines.AddReferencedAssembly(_setting.ScriptAsmReferences);
            }
            ScriptEngines.RegisterModelChangedBefore(OnModelChangeBefore);
            ScriptEngines.RegisterModelChangedAfter(OnModelChangeAtfer);
            ScriptEngines.OnLoaded += OnScriptLoaded;
            ScriptEngines.Initialize();
            Language.SetLang();
            CacheFactory.Initialize(cacheSetting, _setting.Serializer);
            EntitySchemaSet.StartCheckTableTimer();
            Global = new ContextCacheSet <CacheItem>("__gameenvironment_global");
        }
Exemplo n.º 5
0
        /// <summary>
        /// The game service start.
        /// </summary>
        /// <param name="setting">Environment setting.</param>
        /// <param name="cacheSetting">Cache setting.</param>
        public static void Start(EnvironmentSetting setting, CacheSetting cacheSetting)
        {
            if (_isRunning == 1)
            {
                return;
            }

            _setting = setting;
            if (!RedisConnectionPool.CheckConnect())
            {
                string error = string.Format("Error: the redis server is not started.");
                Console.WriteLine(error);
                TraceLog.WriteError(error);
                return;
            }
            DbConnectionProvider.Initialize();
            EntitySchemaSet.CacheGlobalPeriod = _setting.CacheGlobalPeriod;
            EntitySchemaSet.CacheUserPeriod   = _setting.CacheUserPeriod;
            if (_setting.EntityAssembly != null)
            {
                ProtoBufUtils.LoadProtobufType(_setting.EntityAssembly);
                EntitySchemaSet.LoadAssembly(_setting.EntityAssembly);
            }
            EntitySchemaSet.StartCheckTableTimer();
            LoadGameEntitySchema();
            ZyGameBaseConfigManager.Intialize();
            //init script.
            if (_setting.ScriptSysAsmReferences.Length > 0)
            {
                ScriptEngines.AddSysReferencedAssembly(_setting.ScriptSysAsmReferences);
            }
            ScriptEngines.AddReferencedAssembly("ZyGames.Framework.Game.dll");
            if (_setting.ScriptAsmReferences.Length > 0)
            {
                ScriptEngines.AddReferencedAssembly(_setting.ScriptAsmReferences);
            }
            ScriptEngines.RegisterModelChangedBefore(OnModelChangeBefore);
            ScriptEngines.RegisterModelChangedAfter(OnModelChangeAtfer);
            ScriptEngines.Initialize();
            Language.SetLang();
            CacheFactory.Initialize(cacheSetting);
            Global = new ContextCacheSet <CacheItem>("__gameenvironment_global");
            Interlocked.Exchange(ref _isRunning, 1);
        }
Exemplo n.º 6
0
 static void Main(string[] args)
 {
     try
     {
         autoTest tasks = new autoTest();
         ScriptEngines.AddReferencedAssembly("ZyGames.Test.dll");
         ScriptEngines.AddReferencedAssembly("GameRanking.Pack.dll");
         ScriptEngines.AddReferencedAssembly("Protocol.dll");
         ScriptEngines.AddReferencedAssembly("Utils.dll");
         ScriptEngines.Initialize();
         tasks.RunTasks();
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
         TraceLog.WriteError("Main error:{0}", ex);
         Console.ReadKey();
     }
 }
Exemplo n.º 7
0
        static void Main(string[] args)
        {
            try
            {
                var setting = new TaskSetting();
                ScriptEngines.AddReferencedAssembly("ZyGames.Test.dll");
                ScriptEngines.Initialize();

                Console.WriteLine("===============================");
                Console.WriteLine("Stress Test");
                Console.WriteLine("Option:");
                Console.WriteLine("\tPress \"Esc\" is exits!");
                Console.WriteLine("===============================");
                Console.WriteLine("Press any key start run");
                if (Console.ReadKey().Key == ConsoleKey.Escape)
                {
                    return;
                }
                Console.WriteLine("Running...");

                //ThreadCaseWork<CaseStep> testCase = new ThreadCaseWork<CaseStep>();

                while (true)
                {
                    string result = ThreadManager.RunTest(setting);
                    //string result = testCase.RunTest(setting);
                    Console.WriteLine(result);
                    TraceLog.ReleaseWrite(result);
                    Console.WriteLine("Press any key to continue.");
                    if (Console.ReadKey().Key == ConsoleKey.Escape)
                    {
                        break;
                    }
                    Console.WriteLine("Running...");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                TraceLog.WriteError("Main error:{0}", ex);
                Console.ReadKey();
            }
        }