Esempio n. 1
0
 public void Stop()
 {
     StopService(); // 关闭网络等等。
     Zeze.Stop();   // 关闭数据库
     StopModules(); // 关闭模块,,卸载配置什么的。
     Destroy();
 }
Esempio n. 2
0
 public void Start()
 {
     Create();
     StartModules(); // 启动模块,装载配置什么的。
     Zeze.Start();   // 启动数据库
     StartService(); // 启动网络
 }
Esempio n. 3
0
File: App.cs Progetto: e2wugui/zeze
 public void Start(Zeze.Config config = null)
 {
     Create(config);
     StartModules(); // 启动模块,装载配置什么的。
     Zeze.Start();   // 启动数据库
     StartService(); // 启动网络等等。
 }
Esempio n. 4
0
        public override void DispatchProtocol(Protocol p, ProtocolFactoryHandle factoryHandle)
        {
            // 防止Client不进入加密,直接发送用户协议。
            if (false == IsHandshakeProtocol(p.TypeId))
            {
                p.Sender.VerifySecurity();
            }

            if (p.TypeId == gnet.Provider.ModuleRedirect.TypeId_)
            {
                if (null != factoryHandle.Handle)
                {
                    var modureRecirect = p as gnet.Provider.ModuleRedirect;
                    if (null != Zeze && false == factoryHandle.NoProcedure)
                    {
                        Zeze.TaskOneByOneByKey.Execute(
                            modureRecirect.Argument.HashCode,
                            () => global::Zeze.Util.Task.Call(
                                Zeze.NewProcedure(
                                    () => factoryHandle.Handle(p),
                                    p.GetType().FullName,
                                    p.UserState),
                                p,
                                (p, code) => p.SendResultCode(code)
                                )
                            );
                    }
                    else
                    {
                        Zeze.TaskOneByOneByKey.Execute(modureRecirect.Argument.HashCode,
                                                       () => global::Zeze.Util.Task.Call(
                                                           () => factoryHandle.Handle(p),
                                                           p,
                                                           (p, code) => p.SendResultCode(code)
                                                           )
                                                       );
                    }
                }
                else
                {
                    logger.Log(SocketOptions.SocketLogLevel, "Protocol Handle Not Found. {0}", p);
                }
                return;
            }

            base.DispatchProtocol(p, factoryHandle);
        }
Esempio n. 5
0
        public int ProcessReduceRequest(Zeze.Net.Protocol p)
        {
            GlobalCacheManager.Reduce rpc = (GlobalCacheManager.Reduce)p;
            switch (rpc.Argument.State)
            {
            case GlobalCacheManager.StateInvalid:
                return(Zeze.GetTable(rpc.Argument.GlobalTableKey.TableName).ReduceInvalid(rpc));

            case GlobalCacheManager.StateShare:
                return(Zeze.GetTable(rpc.Argument.GlobalTableKey.TableName).ReduceShare(rpc));

            default:
                rpc.Result = rpc.Argument;
                rpc.SendResultCode(GlobalCacheManager.ReduceErrorState);
                return(0);
            }
        }
Esempio n. 6
0
 // 用来派发异步rpc回调。
 public virtual void DispatchRpcResponse(Protocol rpc,
                                         Func <Protocol, int> responseHandle,
                                         ProtocolFactoryHandle factoryHandle)
 {
     if (null != Zeze && false == factoryHandle.NoProcedure)
     {
         global::Zeze.Util.Task.Run(
             Zeze.NewProcedure(
                 () => responseHandle(rpc),
                 rpc.GetType().FullName + ":Response",
                 rpc.UserState));
     }
     else
     {
         global::Zeze.Util.Task.Run(() => responseHandle(rpc), rpc);
     }
 }
Esempio n. 7
0
File: App.cs Progetto: e2wugui/zeze
        public void Start(string[] args)
        {
            int AutoKeyLocalId = -1;

            for (int i = 0; i < args.Length; ++i)
            {
                switch (args[i])
                {
                case "-AutoKeyLocalId":
                    AutoKeyLocalId = int.Parse(args[++i]);
                    break;
                }
            }

            LoadConfig();
            var config = global::Zeze.Config.Load();

            if (AutoKeyLocalId != -1)
            {
                config.AutoKeyLocalId = AutoKeyLocalId; // replace from args
            }
            Create(config);

            ProviderModuleBinds = ProviderModuleBinds.Load();
            ProviderModuleBinds.BuildStaticBinds(Modules, Zeze.Config.AutoKeyLocalId, StaticBinds);

            StartModules(); // 启动模块,装载配置什么的。
            Zeze.Start();   // 启动数据库
            StartService(); // 启动网络
            ServiceManagerAgent = new Zeze.Services.ServiceManager.Agent(config,
                                                                         (agent) =>
            {
                foreach (var staticBind in StaticBinds)
                {
                    agent.RegisterService($"{GameServerServiceNamePrefix}{staticBind.Key}",
                                          config.AutoKeyLocalId.ToString());
                }
                agent.SubscribeService(GameLinkdServiceName, global::Zeze.Services.ServiceManager.SubscribeInfo.SubscribeTypeSimple);
            },
                                                                         (subscribeState) =>
            {
                Server.ApplyLinksChanged(subscribeState.ServiceInfos);
            });
            Load.StartTimerTask();
        }
Esempio n. 8
0
 public virtual void DispatchProtocol(Protocol p, ProtocolFactoryHandle factoryHandle)
 {
     if (null != factoryHandle.Handle)
     {
         if (null != Zeze && false == factoryHandle.NoProcedure)
         {
             global::Zeze.Util.Task.Run(
                 Zeze.NewProcedure(
                     () => factoryHandle.Handle(p),
                     p.GetType().FullName,
                     p.UserState), p);
         }
         else
         {
             global::Zeze.Util.Task.Run(() => factoryHandle.Handle(p), p);
         }
     }
     else
     {
         logger.Log(SocketOptions.SocketLogLevel, "Protocol Handle Not Found. {0}", p);
     }
 }
Esempio n. 9
0
File: App.cs Progetto: e2wugui/zeze
        public void Start()
        {
            LoadConfig();
            Create();
            StartModules(); // 启动模块,装载配置什么的。
            Zeze.Start();   // 启动数据库
            StartService(); // 启动网络

            var(ip, port)             = ProviderService.GetOnePassiveAddress();
            ProviderServicePassiveIp  = ip;
            ProviderServicePasivePort = port;

            ServiceManagerAgent = new Zeze.Services.ServiceManager.Agent(Zeze.Config,
                                                                         (agent) =>
            {
                agent.RegisterService(GameLinkdServiceName,
                                      $"{ProviderServicePassiveIp}:{ProviderServicePasivePort}",
                                      ProviderServicePassiveIp, ProviderServicePasivePort);
            },
                                                                         (subscribeState) =>
            {
                // 不需要做任何操作,直接使用得到的服务列表。
            });
        }
Esempio n. 10
0
File: App.cs Progetto: e2wugui/zeze
 public void Start()
 {
     StartModules(); // 启动模块,装载配置什么的。
     Zeze.Start();   // 启动数据库
     // 启动网络等等。
 }
Esempio n. 11
0
File: App.cs Progetto: e2wugui/zeze
 public void Stop()
 {
     // 关闭网络等等。
     Zeze.Stop();   // 关闭数据库
     StopModules(); // 关闭模块,,卸载配置什么的。
 }