protected override async ETTask Run(Session session, A0004_PlayerOnline_G2R message)
        {
            OnlineComponent onlineComponent = Game.Scene.GetComponent <OnlineComponent>();

            //检查玩家是否在线 如不在线则添加
            if (onlineComponent.GetGateAppId(message.UserID) == 0)
            {
                onlineComponent.Add(message.UserID, message.GateAppID);
            }
            else
            {
                Log.Error("玩家已在线 Realm服务器收到重复上线请求的异常");
            }
        }
Example #2
0
        private async ETVoid RunAsync(Session session, G2R_LandlordsOnline message, Action <EmptyResponse> reply)
        {
            EmptyResponse respone = new EmptyResponse();

            try
            {
                OnlineComponent onlineComponent = Game.Scene.GetComponent <OnlineComponent>();
                // 踢掉旧连接
                await onlineComponent.KickPlayer(message.UserId);

                onlineComponent.Add(message.UserId, message.GateAppId);

                reply(respone);
            }
            catch (Exception e) {
                ReplyError(respone, e, reply);
            }
        }
Example #3
0
        public static async ETVoid KickPlayer(this OnlineComponent self, long userId)
        {
            long gateAppId = Game.Scene.GetComponent <OnlineComponent>().Get(userId);

            if (gateAppId != 0)
            {
                // 方式一 通过ActorLocationSenderComponent
                // var actorMessageSender = Game.Scene.GetComponent<ActorLocationSenderComponent>().Get(userId);
                // await actorMessageSender.Call(new Actor_LandlordsKickPlayer() { UserId = userId });

                // 方式二 通过gateAppId获取对应app地址
                var ipEndPoint  = StartConfigComponent.Instance.GetInnerAddress(IdGenerater.GetAppId(gateAppId));
                var gateSession = Game.Scene.GetComponent <NetInnerComponent>().Get(ipEndPoint);
                await gateSession.Call(new R2G_LandlordsKickPlayer()
                {
                    UserId = userId
                });
            }
        }
Example #4
0
        protected override async void Run(Session session, G2R_PlayerOnline_Req message, Action <R2G_PlayerOnline_Res> reply)
        {
            R2G_PlayerOnline_Res response = new R2G_PlayerOnline_Res();

            try
            {
                OnlineComponent onlineComponent = Game.Scene.GetComponent <OnlineComponent>();

                await RealmHelper.KickOutPlayer(message.UserID);

                onlineComponent.Add(message.UserID, message.GateAppID);

                Log.Info($"玩家{message.UserID}上线");

                reply(response);
            }
            catch (Exception e)
            {
                ReplyError(response, e, reply);
            }
        }
Example #5
0
        protected override async void Run(Session session, G2R_PlayerOnline message, Action <R2G_PlayerOnline> reply)
        {
            R2G_PlayerOnline response = new R2G_PlayerOnline();

            try
            {
                OnlineComponent onlineComponent = Game.Scene.GetComponent <OnlineComponent>();

                //将已在线玩家踢下线
                await RealmHelper.KickOutPlayer(message.UserId);

                //玩家上线
                onlineComponent.Add(message.UserId, message.GateAppId);
                Log.Info($"玩家{message.UserId}上线");

                reply(response);
            }
            catch (Exception e)
            {
                ReplyError(response, e, reply);
            }
        }