Exemple #1
0
        protected override async void Run(Session session, C2M_Reload message, Action <M2C_Reload> reply)
        {
            M2C_Reload response = new M2C_Reload();

            try
            {
                StartConfigComponent startConfigComponent = Game.Scene.GetComponent <StartConfigComponent>();
                NetInnerComponent    netInnerComponent    = Game.Scene.GetComponent <NetInnerComponent>();
                foreach (StartConfig startConfig in startConfigComponent.GetAll())
                {
                    if (!message.AppType.Is(startConfig.AppType))
                    {
                        continue;
                    }
                    InnerConfig innerConfig   = startConfig.GetComponent <InnerConfig>();
                    Session     serverSession = netInnerComponent.Get(innerConfig.Address);
                    await serverSession.Call <M2A_Reload, A2M_Reload>(new M2A_Reload());
                }
                reply(response);
            }
            catch (Exception e)
            {
                ReplyError(response, e, reply);
            }
        }
Exemple #2
0
        private async ETVoid RunAsync(Session session, C2M_Reload message, Action <M2C_Reload> reply)
        {
            M2C_Reload response = new M2C_Reload();

            if (message.Account != "panda" && message.Password != "panda")
            {
                Log.Error($"error reload account and password: {MongoHelper.ToJson(message)}");
                return;
            }
            try
            {
                StartConfigComponent startConfigComponent = Game.Scene.GetComponent <StartConfigComponent>();
                NetInnerComponent    netInnerComponent    = Game.Scene.GetComponent <NetInnerComponent>();
                foreach (StartConfig startConfig in startConfigComponent.GetAll())
                {
                    InnerConfig innerConfig   = startConfig.GetComponent <InnerConfig>();
                    Session     serverSession = netInnerComponent.Get(innerConfig.IPEndPoint);
                    await serverSession.Call(new M2A_Reload());
                }
                reply(response);
            }
            catch (Exception e)
            {
                ReplyError(response, e, reply);
            }
        }
Exemple #3
0
        protected override async void Run(Session session, C2M_Reload message, Action <M2C_Reload> reply)
        {
            M2C_Reload response = new M2C_Reload();

            if (message.Account != "panda" && message.Password != "panda")
            {
                Log.Error($"error reload account and password: {MongoHelper.ToJson(message)}");
                return;
            }
            try
            {
                //获得启动配置
                StartConfigComponent startConfigComponent = Game.Scene.GetComponent <StartConfigComponent>();
                //拿到内网通讯组件
                NetInnerComponent netInnerComponent = Game.Scene.GetComponent <NetInnerComponent>();
                //遍历所有的服务器配置
                foreach (StartConfig startConfig in startConfigComponent.GetAll())
                {
                    InnerConfig innerConfig   = startConfig.GetComponent <InnerConfig>();      //拿到当前服务器的ip端口
                    Session     serverSession = netInnerComponent.Get(innerConfig.IPEndPoint); //得到内部会话serverSession
                    await serverSession.Call(new M2A_Reload());                                //发送RPC消息等待完成
                }
                reply(response);                                                               //回复RPC消息
            }
            catch (Exception e)
            {
                ReplyError(response, e, reply);
            }
        }
        protected override async void Run(Session session, C2M_Reload message, Action <M2C_Reload> reply)
        {
            M2C_Reload m2CReload = new M2C_Reload();

            try
            {
                StartConfigComponent startConfigComponent = Game.Scene.GetComponent <StartConfigComponent>();
                NetInnerComponent    netInnerComponent    = Game.Scene.GetComponent <NetInnerComponent>();
                foreach (StartConfig startConfig in startConfigComponent.GetAll())
                {
                    if (!message.AppType.Is(startConfig.AppType))
                    {
                        continue;
                    }
                    InnerConfig innerConfig   = startConfig.GetComponent <InnerConfig>();
                    Session     serverSession = netInnerComponent.Get(innerConfig.Address);
                    await serverSession.Call <M2A_Reload, A2M_Reload>(new M2A_Reload());
                }
            }
            catch (Exception e)
            {
                m2CReload.Error   = ErrorCode.ERR_ReloadFail;
                m2CReload.Message = e.ToString();
            }
            reply(m2CReload);
        }
Exemple #5
0
        protected override async void Run(Session session, M2A_RegisterService message)
        {
            try
            {
                StartConfig          startConfig          = (StartConfig)message.Component;
                NetInnerComponent    netInnerComponent    = Game.Scene.GetComponent <NetInnerComponent>();
                StartConfigComponent startConfigComponent = Game.Scene.GetComponent <StartConfigComponent>();
                startConfigComponent.AddConfig(startConfig);

                if (startConfig.AppId == (int)IdGenerater.AppId)
                {
                    return;
                }
                InnerConfig        innerConfig        = startConfig.GetComponent <InnerConfig>();
                Session            serverSession      = netInnerComponent.Get(innerConfig.IPEndPoint);
                A2S_ConnectService a2S_ConnectService = (A2S_ConnectService)await serverSession.Call(new S2A_ConnectService());

                if (a2S_ConnectService.Error != ErrorCode.ERR_Success)
                {
                    Log.Error($"to connect service[{startConfig.AppType}:{startConfig.AppId}] is failed.");
                }
                else
                {
                    Log.Info($"to connect service[{startConfig.AppType}:{startConfig.AppId}] is successful.");
                }
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
        }
        protected override void Run(Session session, S2M_RegisterService message, Action <M2S_RegisterService> reply)
        {
            M2S_RegisterService response = new M2S_RegisterService();

            try
            {
                NetInnerComponent    netInnerComponent    = Game.Scene.GetComponent <NetInnerComponent>();
                StartConfigComponent startConfigComponent = Game.Scene.GetComponent <StartConfigComponent>();
                MasterComponent      masterComponent      = Game.Scene.GetComponent <MasterComponent>();

                StartConfig startConfig = (StartConfig)message.Component;
                if (!masterComponent.AddConfig(startConfig))
                {
                    response.Error = ErrorCode.ERR_RegisterServerRepeatly;
                    reply(response);
                    return;
                }
                else
                {
                    Log.Info($"Server[{startConfig.AppType}:{startConfig.AppId}] is online.");
                }

                startConfigComponent.AddConfig(startConfig);

                var startConfigs = masterComponent.GetAll();
                response.Components = startConfigs.Select(e => (ComponentWithId)e).ToList();
                reply(response);

                foreach (StartConfig v in startConfigs)
                {
                    // 不傳給自己
                    if (v.AppId == startConfig.AppId)
                    {
                        continue;
                    }
                    InnerConfig innerConfig   = v.GetComponent <InnerConfig>();
                    Session     serverSession = netInnerComponent.Get(innerConfig.IPEndPoint);
                    serverSession.Send(new M2A_RegisterService
                    {
                        Component = startConfig
                    });
                }
            }
            catch (Exception e)
            {
                ReplyError(response, e, reply);
            }
        }
Exemple #7
0
        protected override async ETTask Run(Session session, C2M_Reload request, M2C_Reload response, Action reply)
        {
            if (request.Account != "panda" && request.Password != "panda")
            {
                Log.Error($"error reload account and password: {MongoHelper.ToJson(request)}");
                return;
            }
            StartConfigComponent startConfigComponent = Game.Scene.GetComponent <StartConfigComponent>();
            NetInnerComponent    netInnerComponent    = Game.Scene.GetComponent <NetInnerComponent>();

            foreach (StartConfig startConfig in startConfigComponent.GetAll())
            {
                InnerConfig innerConfig   = startConfig.GetComponent <InnerConfig>();
                Session     serverSession = netInnerComponent.Get(innerConfig.IPEndPoint);
                await serverSession.Call(new M2A_Reload());
            }
            reply();
        }