Exemplo n.º 1
0
        static void Main(string[] args)
        {
            GameHostApp instance = null;
            string date = DateTime.Now.ToString("HH:mm:ss");
            try
            {
                var setting = new EnvironmentSetting();
                Console.WriteLine(string.Format(CharFormat,
                    "6.1.6.5",
                    setting.ProductCode,
                    setting.ProductServerId,
                    setting.GamePort));
                GameEnvironment.Start(setting);
                instance = new GameHostApp();
                instance.Start(args);
                Console.WriteLine("{0} Server has started successfully!", date);
                Console.WriteLine("# Server is listening...");

            }
            catch (Exception ex)
            {
                Console.WriteLine("{0} Server failed to start!", date);
                TraceLog.WriteError("HostServer error:{0}", ex);
            }
            finally
            {
                Console.ReadKey();
                if (instance != null) instance.Stop();
            }
        }
Exemplo n.º 2
0
        protected override void OnStartAffer()
        {
            try
            {
                var setting = new EnvironmentSetting();
                setting.EntityAssembly = Assembly.Load("GameRanking.Model");
                setting.ScriptStartBeforeHandle += () =>
                {
                    ScriptEngines.AddReferencedAssembly("GameRanking.Model.dll");
                    ActionFactory.SetActionIgnoreAuthorize(1000, 1001);

                    var cache = new ShareCacheStruct<UserRanking>();
                    Stopwatch t = new Stopwatch();
                    t.Start();
                    var list = cache.FindAll(false);
                    t.Stop();
                    if(list.Count > 0)
                    {

                    }
                };

                var cacheSetting = new CacheSetting();
                cacheSetting.ChangedHandle += OnChangedNotify;
                GameEnvironment.Start(setting, cacheSetting);
                Console.WriteLine("The server is staring...");
            }
            catch (Exception ex)
            {
                TraceLog.WriteError("App star error:{0}", ex);
            }
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            GameHostApp instance = null;
            string date = DateTime.Now.ToString("HH:mm:ss");
            try
            {
                var fc = Console.ForegroundColor;
                Console.ForegroundColor = ConsoleColor.DarkYellow;
                var setting = new EnvironmentSetting();
                setting.ClientDesDeKey = "j6=9=1ac";
                setting.EntityAssembly = Assembly.Load("ZyGames.Moshouxingkong.Model");

                Console.WriteLine(string.Format(CharFormat,
                    "6.3.7.500",
                    setting.ProductCode,
                    setting.ProductServerId,
                    setting.GamePort));
                GameEnvironment.Start(setting);
                Console.ForegroundColor = fc;
                instance = new GameHostApp();
                instance.Start(args);
                Console.WriteLine("{0} Server has started successfully!", date);
                Console.WriteLine("# Server is listening...");
            }
            catch (Exception ex)
            {
                Console.WriteLine("{0} Server failed to start!", date);
                TraceLog.WriteError("HostServer error:{0}", ex);
            }
            finally
            {
                Console.ReadKey();
                if (instance != null) instance.Stop();
            }
        }
Exemplo n.º 4
0
 static void Main(string[] args)
 {
     try
     {
         ConsoleColor currentForeColor = Console.ForegroundColor;
         var setting = new EnvironmentSetting();
         Console.ForegroundColor = ConsoleColor.DarkYellow;
         Console.WriteLine(string.Format(CharFormat,
             Assembly.GetExecutingAssembly().GetName().Version,
             setting.ProductCode,
             setting.ProductServerId,
             setting.GamePort));
         GameEnvironment.Start(setting);
         Console.ForegroundColor = currentForeColor;
         if (ScriptEngines.RunMainProgram(args))
         {
             Console.WriteLine("{0} Server has started successfully!", DateTime.Now.ToString("HH:mm:ss"));
             Console.WriteLine("# Server is listening...");
         }
         else
         {
             Console.WriteLine("{0} Server failed to start!", DateTime.Now.ToString("HH:mm:ss"));
         }
         Console.ReadKey();
         ScriptEngines.StopMainProgram();
     }
     catch (Exception ex)
     {
         Console.WriteLine("{0} Server failed to start!", DateTime.Now.ToString("HH:mm:ss"));
         TraceLog.WriteError("Server failed to start error:{0}", ex);
         Console.ReadKey();
     }
 }
Exemplo n.º 5
0
        protected override void OnStartAffer()
        {
            try
            {
                var setting = new EnvironmentSetting();
                setting.ClientDesDeKey = "j6=9=1ac";
                setting.EntityAssembly = Assembly.Load("Maximus.Model");
                GameEnvironment.Start(setting);

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

                AppstoreClientManager.Current.InitConfig();
                LoadUnlineUser();
                InitRanking();
            }
            catch (Exception ex)
            {
                TraceLog.WriteError("OnStartAffer error:{0}", ex);
            }
        }
Exemplo n.º 6
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");
                setting.ScriptStartBeforeHandle += () =>
                {
                    SystemGlobal.Run();

                    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);

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

            cacheSetting.ChangedHandle += EntitySyncManger.OnChange;
            Start(setting, cacheSetting);
        }
        /// <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.º 9
0
 protected override void OnStartAffer()
 {
     try
     {
         EnvironmentSetting setting = new EnvironmentSetting();
         GameEnvironment.Start(setting);
         Console.WriteLine("The server is staring...");
     }
     catch (Exception ex)
     {
         Console.WriteLine("error:{0}", ex.Message);
     }
 }
Exemplo n.º 10
0
        /// <summary>
        /// 
        /// </summary>
        protected GameSocketHost()
        {
            _setting = GameEnvironment.Setting;
            int port = _setting != null ? _setting.GamePort : 0;
            IPEndPoint localEndPoint = new IPEndPoint(IPAddress.Any, port);

            var section = GetSection();
            int maxConnections = section.SocketMaxConnection;
            int backlog = section.SocketBacklog;
            int maxAcceptOps = section.SocketMaxAcceptOps;
            int bufferSize = section.SocketBufferSize;
            int expireInterval = section.SocketExpireInterval;
            int expireTime = section.SocketExpireTime;

            //threadPool = new SmartThreadPool(180 * 1000, 100, 5);
            //threadPool.Start();

            var socketSettings = new SocketSettings(maxConnections, backlog, maxAcceptOps, bufferSize, localEndPoint, expireInterval, expireTime);
            socketListener = new SocketListener(socketSettings);
            socketListener.DataReceived += new ConnectionEventHandler(socketLintener_DataReceived);
            socketListener.Connected += new ConnectionEventHandler(socketLintener_OnConnectCompleted);
            socketListener.Disconnected += new ConnectionEventHandler(socketLintener_Disconnected);


            httpListener = new HttpListener();
            var httpHost = section.HttpHost;
            var httpPort = section.HttpPort;
            var httpName = section.HttpName;

            if (!string.IsNullOrEmpty(httpHost))
            {
                EnableHttp = true;
                var hosts = httpHost.Split(',');
                foreach (var point in hosts)
                {
                    var addressList = point.Split(':');
                    string host = addressList[0];
                    int hport = httpPort;
                    if (addressList.Length > 1)
                    {
                        int.TryParse(addressList[1], out hport);
                    }

                    string address = host.StartsWith("http", StringComparison.InvariantCultureIgnoreCase)
                                         ? host
                                         : "http://" + host;
                    httpListener.Prefixes.Add(string.Format("{0}:{1}/{2}/", address, hport, httpName));
                }
            }
        }
Exemplo n.º 11
0
        static void Main(string[] args)
        {
            GameHostApp instance = null;
            string date = DateTime.Now.ToString("HH:mm:ss");
            try
            {
                var fc = Console.ForegroundColor;
                Console.ForegroundColor = ConsoleColor.DarkYellow;
                var setting = new EnvironmentSetting();
                setting.ClientDesDeKey = "j6=9=1ac";
                setting.EntityAssembly = Assembly.Load("ZyGames.Doudizhu.Model");

                Console.WriteLine(string.Format(CharFormat,
                    "6.3.7.500",
                    setting.ProductCode,
                    setting.ProductServerId,
                    setting.GamePort));
                GameEnvironment.Start(setting);
                Console.ForegroundColor = fc;
                instance = new GameHostApp();
                instance.Start(args);
                Console.WriteLine("{0} Server has started successfully!", date);
                Console.WriteLine("# Server is listening...");
                //Task.Factory.StartNew(() =>
                //{
                //    while (true)
                //    {
                //        var cacheSet = new GameDataCacheSet<GameUser>();
                //        var user = cacheSet.FindKey("1380001");
                //        if (user != null && user.Property.OnLine)
                //        {
                //            TraceLog.ReleaseWriteDebug("user:{0},tabls:{1},room:{2}", user.UserId, user.Property.TableId, user.Property.RoomId);
                //        }
                //        Thread.Sleep(1000);
                //    }
                //});
            }
            catch (Exception ex)
            {
                Console.WriteLine("{0} Server failed to start!", date);
                TraceLog.WriteError("HostServer error:{0}", ex);
            }
            finally
            {
                Console.ReadKey();
                if (instance != null) instance.Stop();
            }
        }
Exemplo n.º 12
0
 protected void Application_Start(object sender, EventArgs e)
 {
     try
     {
         if (!GameEnvironment.IsRunning)
         {
             var setting = new EnvironmentSetting();
             GameEnvironment.Start(setting);
             ScriptEngines.RunMainClass(out _instance);
         }
     }
     catch (Exception ex)
     {
         TraceLog.WriteError("App star error:{0}", ex);
     }
 }
Exemplo n.º 13
0
 /// <summary>
 /// 
 /// </summary>
 public virtual void OnInit()
 {
     try
     {
         _setting = new EnvironmentSetting();
         var osbit = GetOsBit();
         var platform = GetRunPlatform();
         TraceLog.WriteLine(string.Format(CharFormat,
             Assembly.GetExecutingAssembly().GetName().Version,
             osbit,
             platform,
             _setting.ProductCode,
             _setting.ProductServerId));
     }
     catch
     {
     }
 }
Exemplo n.º 14
0
 /// <summary>
 ///
 /// </summary>
 public virtual void OnInit()
 {
     try
     {
         _setting = new EnvironmentSetting();
         var osbit    = GetOsBit();
         var platform = GetRunPlatform();
         TraceLog.WriteLine(string.Format(CharFormat,
                                          Assembly.GetExecutingAssembly().GetName().Version,
                                          osbit,
                                          platform,
                                          _setting.ProductCode,
                                          _setting.ProductServerId));
     }
     catch
     {
     }
 }
Exemplo n.º 15
0
 protected void Application_Start(object sender, EventArgs e)
 {
     try
     {
         var setting = new EnvironmentSetting();
         setting.EntityAssembly = Assembly.Load("GameRanking.Model");
         setting.ScriptStartBeforeHandle += () =>
         {
             ScriptEngines.AddReferencedAssembly("GameRanking.Model.dll");
             ActionFactory.SetActionIgnoreAuthorize(1000, 1001);
         };
         GameEnvironment.Start(setting);
     }
     catch (Exception ex)
     {
         TraceLog.WriteError("App star error:{0}", ex);
     }
 }
Exemplo n.º 16
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.º 17
0
 /// <summary>
 /// Process start logic init
 /// </summary>
 /// <returns></returns>
 public virtual bool OnStart()
 {
     try
     {
         var setting = new EnvironmentSetting();
         TraceLog.WriteLine(string.Format(CharFormat,
                                          Assembly.GetExecutingAssembly().GetName().Version,
                                          setting.ProductCode,
                                          setting.ProductServerId,
                                          setting.GamePort));
         GameEnvironment.Start(setting);
     }
     catch (Exception ex)
     {
         TraceLog.WriteLine("{0} Server failed to start error:{1}", DateTime.Now.ToString("HH:mm:ss"), ex.Message);
         TraceLog.WriteError("OnInit error:{0}", ex);
     }
     return(true);
 }
Exemplo n.º 18
0
 protected override void OnStartAffer()
 {
     try
     {
         var setting = new EnvironmentSetting();
         setting.EntityAssembly = Assembly.Load("GameRanking.Model");
         setting.ScriptStartBeforeHandle += () =>
         {
             ScriptEngines.AddReferencedAssembly("GameRanking.Model.dll");
             ActionFactory.SetActionIgnoreAuthorize(1000, 1001);
         };
         GameEnvironment.Start(setting);
         Console.WriteLine("The server is staring...");
     }
     catch (Exception ex)
     {
         TraceLog.WriteError("App star error:{0}", ex);
     }
 }
Exemplo n.º 19
0
        protected override void OnStartAffer()
        {
            try
            {
                var setting = new EnvironmentSetting();
                setting.ScriptStartBeforeHandle += () =>
                {
                    ActionFactory.SetActionIgnoreAuthorize(2001, 404);
                    InitNotice();
                };
                GameEnvironment.Start(setting);
                Console.WriteLine("The server is staring...");

            }
            catch (Exception ex)
            {
                TraceLog.WriteError("The server start error:{0}", ex);
            }
        }
Exemplo n.º 20
0
 /// <summary>
 /// Process start logic init
 /// </summary>
 /// <returns></returns>
 public virtual bool OnStart()
 {
     try
     {
         var setting = new EnvironmentSetting();
         TraceLog.WriteLine(string.Format(CharFormat,
             Assembly.GetExecutingAssembly().GetName().Version,
             setting.ProductCode,
             setting.ProductServerId,
             setting.GamePort));
         GameEnvironment.Start(setting);
         return true;
     }
     catch (Exception ex)
     {
         TraceLog.WriteLine("{0} Server failed to start error:{1}", DateTime.Now.ToString("HH:mm:ss"), ex.Message);
         TraceLog.WriteError("OnInit error:{0}", ex);
     }
     return false;
 }
Exemplo n.º 21
0
        /// <summary>
        /// 
        /// </summary>
        protected GameSocketHost()
        {
            _setting = GameEnvironment.Setting;
            int port = _setting != null ? _setting.GamePort : 0;
            IPEndPoint localEndPoint = new IPEndPoint(IPAddress.Any, port);

            int maxConnections = ConfigUtils.GetSetting("MaxConnections", 10000);
            int backlog = ConfigUtils.GetSetting("Backlog", 1000);
            int maxAcceptOps = ConfigUtils.GetSetting("MaxAcceptOps", 1000);
            int bufferSize = ConfigUtils.GetSetting("BufferSize", 8192);
            int expireInterval = ConfigUtils.GetSetting("ExpireInterval", 600) * 1000;
            int expireTime = ConfigUtils.GetSetting("ExpireTime", 3600) * 1000;

            //threadPool = new SmartThreadPool(180 * 1000, 100, 5);
            //threadPool.Start();

            var socketSettings = new SocketSettings(maxConnections, backlog, maxAcceptOps, bufferSize, localEndPoint, expireInterval, expireTime);
            socketLintener = new SocketListener(socketSettings);
            socketLintener.DataReceived += new ConnectionEventHandler(socketLintener_DataReceived);
            socketLintener.Connected += new ConnectionEventHandler(socketLintener_OnConnectCompleted);
            socketLintener.Disconnected += new ConnectionEventHandler(socketLintener_Disconnected);


            httpListener = new HttpListener();
            var httpHost = ConfigUtils.GetSetting("Game.Http.Host");
            var httpPort = ConfigUtils.GetSetting("Game.Http.Port", 80);
            var httpName = ConfigUtils.GetSetting("Game.Http.Name", "Service.aspx");

            if (!string.IsNullOrEmpty(httpHost))
            {
                EnableHttp = true;
                var hosts = httpHost.Split(',');
                foreach (var host in hosts)
                {
                    string address = host.StartsWith("http", StringComparison.InvariantCultureIgnoreCase)
                                         ? host
                                         : "http://" + host;
                    httpListener.Prefixes.Add(string.Format("{0}:{1}/{2}/", address, httpPort, httpName));
                }
            }
        }
Exemplo n.º 22
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="requestHandler"></param>
        protected GameWebSocketHost(WebSocketRequestHandler requestHandler) {
            _setting = GameEnvironment.Setting;
            int port = _setting != null ? _setting.GamePort : 0;
            IPEndPoint localEndPoint = new IPEndPoint(IPAddress.Any, port);

            var section = GetSection();
            int maxConnections = section.SocketMaxConnection;
            int backlog = section.SocketBacklog;
            int maxAcceptOps = section.SocketMaxAcceptOps;
            int bufferSize = section.SocketBufferSize;
            int expireInterval = section.SocketExpireInterval;
            int expireTime = section.SocketExpireTime;

            var socketSettings = new SocketSettings(maxConnections, backlog, maxAcceptOps, bufferSize, localEndPoint, expireInterval, expireTime);
            socketListener = new SocketListener(socketSettings, requestHandler);
            socketListener.DataReceived += DataReceivedEventHandler;
            socketListener.Connected += ConnectedEventHandler;
            socketListener.Disconnected += DisconnectedEventHandler;
            socketListener.Handshaked += HandshakedEventHandler;
            socketListener.OnPing += OnPingEventHandler;
            socketListener.OnPong += OnPongEventHandler;
            socketListener.OnClosedStatus += OnClosedStatusEventHandler;
        }
Exemplo n.º 23
0
        static void Main(string[] args)
        {
            string date = DateTime.Now.ToString("HH:mm:ss");
            try
            {
                var setting = new EnvironmentSetting();
                Console.WriteLine(string.Format(CharFormat,
                    "6.2.7.0",
                    setting.ProductCode,
                    setting.ProductServerId,
                    setting.GamePort));
                GameEnvironment.Start(setting);

                dynamic instance;
                if (ScriptEngines.RunMainClass(out instance, args))
                {
                    Console.WriteLine("{0} Server has started successfully!", date);
                    Console.WriteLine("# Server is listening...");
                }
                else
                {
                    Console.WriteLine("{0} Server failed to start!", date);
                }
                Console.ReadKey();
                if (instance != null)
                {
                    instance.Stop();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("{0} Server failed to start!", date);
                TraceLog.WriteError("Server failed to start error:{0}", ex);
                Console.ReadKey();
            }
        }
Exemplo n.º 24
0
 protected override void OnStartAffer()
 {
     var setting = new EnvironmentSetting();
     GameEnvironment.Start(setting);
 }
Exemplo n.º 25
0
 public void Start()
 {
     var setting = new EnvironmentSetting();
     GameEnvironment.Start(setting);
 }
Exemplo n.º 26
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)
 {
     _setting = setting;
     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();
     CacheFactory.Initialize(cacheSetting);
     Global = new ContextCacheSet<CacheItem>("__gameenvironment_global");
     //init script.
     ScriptEngines.AddReferencedAssembly("ZyGames.Framework.Game.dll");
     ScriptEngines.RegisterModelChangedBefore(OnModelChangeBefore);
     ScriptEngines.RegisterModelChangedAfter(OnModelChangeAtfer);
     _setting.OnScriptStartBefore();
     ScriptEngines.Initialize();
     Interlocked.Exchange(ref _isRunning, 1);
 }
Exemplo n.º 27
0
 protected override void OnStartAffer()
 {
     try
     {
         var setting = new EnvironmentSetting();
         setting.EntityAssembly = Assembly.Load("GameRanking.Model");
         setting.ScriptStartBeforeHandle += () =>
         {
             ScriptEngines.AddReferencedAssembly("GameRanking.Model.dll");
             ActionFactory.SetActionIgnoreAuthorize(1000, 1001);
         };
         GameEnvironment.Start(setting);
         int pushInterval = ConfigUtils.GetSetting("Ranking.PushInterval", 60);
         TimeListener.Append(new PlanConfig(DoPushRanking, true, pushInterval, "GetRanking"));
         Console.WriteLine("The server is staring...");
     }
     catch (Exception ex)
     {
         TraceLog.WriteError("App star error:{0}", ex);
     }
 }
Exemplo n.º 28
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();
            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.º 29
0
 /// <summary>
 /// The game service start.
 /// </summary>
 /// <param name="setting">Environment setting.</param>
 public static void Start(EnvironmentSetting setting)
 {
     CacheSetting cacheSetting = new CacheSetting();
     cacheSetting.ChangedHandle += EntitySyncManger.OnChange;
     Start(setting, cacheSetting);
 }
Exemplo n.º 30
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) 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;
            }
            DbConnectionProvider.Initialize();
            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");
        }