Example #1
0
 private void connection_LoginRecoveryRequested(LoginResponse response)
 {
     if (response != null)
     {
         CafeAuth cafeAuth = null;
         if (this.NxIDToEntityDic.TryGetValue(response.NexonID, out cafeAuth))
         {
             if (response.Result == AuthorizeResult.Allowed)
             {
                 cafeAuth.FrontendConn.RequestOperation(new NotifyCafeAuthResult());
             }
             if (response.Result == AuthorizeResult.Forbidden || response.Result == AuthorizeResult.Terminate)
             {
                 SendPacket op;
                 if (response.Option == Option.AccountShutdowned || (response.ExtendInfos != null && response.ExtendInfos.IsShutDownEnabled))
                 {
                     op = SendPacket.Create <SystemMessage>(new SystemMessage(SystemMessageCategory.Notice, "GameUI_Heroes_Policy_Shutdown"));
                 }
                 else if (response.ExtendInfos != null && response.ExtendInfos.IsShutDownEnabled)
                 {
                     op = SendPacket.Create <SystemMessage>(new SystemMessage(SystemMessageCategory.Notice, "GameUI_Heroes_Policy_IPBlocked"));
                 }
                 else
                 {
                     op = SendPacket.Create <SystemMessage>(new SystemMessage(SystemMessageCategory.Notice, "GameUI_Heroes_Cafe_Expired"));
                 }
                 cafeAuth.FrontendConn.RequestOperation(op);
                 Scheduler.Schedule(base.Thread, Job.Create <CafeAuth>(new Action <CafeAuth>(this.Kick_User), cafeAuth), 5000);
             }
             cafeAuth.SessionNo = response.SessionNo;
             this.WaitQueue.Remove(cafeAuth);
             cafeAuth.SetValid();
         }
     }
 }
Example #2
0
        private void TryLogin(CafeAuth entity)
        {
            AsyncResultSync sync = new AsyncResultSync(base.Thread);

            sync.OnFinished += delegate(ISynchronizable __)
            {
                if (sync != null && this.WaitQueue.Contains(entity))
                {
                    LoginResponse loginResponse = this.connection.EndLogin(sync.AsyncResult);
                    if (loginResponse != null)
                    {
                        if (loginResponse.Result == AuthorizeResult.Allowed)
                        {
                            entity.FrontendConn.RequestOperation(new NotifyCafeAuthResult());
                        }
                        if (loginResponse.Result == AuthorizeResult.Forbidden || loginResponse.Result == AuthorizeResult.Terminate)
                        {
                            SendPacket op = SendPacket.Create <SystemMessage>(new SystemMessage(SystemMessageCategory.Notice, "GameUI_Heroes_Cafe_Expired"));
                            entity.FrontendConn.RequestOperation(op);
                            Scheduler.Schedule(this.Thread, Job.Create <CafeAuth>(new Action <CafeAuth>(this.Kick_User), entity), 5000);
                        }
                        entity.SessionNo = loginResponse.SessionNo;
                        this.WaitQueue.Remove(entity);
                        entity.SetValid();
                    }
                }
            };
            this.connection.BeginLogin(entity.NexonID, entity.CharacterID, entity.LocalAddress, entity.RemoteAddress, entity.CanTry, entity.IsTrial, entity.MID, (entity.GameRoomClient == 0) ? null : new int[]
            {
                entity.GameRoomClient
            }, new AsyncCallback(sync.AsyncCallback), entity);
        }
Example #3
0
 public bool RemoveUser(CafeAuth targetUser)
 {
     if (targetUser == null)
     {
         return(false);
     }
     if (!this.PCRoomNoDic.ContainsValue(targetUser))
     {
         return(false);
     }
     foreach (KeyValuePair <int, CafeAuth> keyValuePair in this.PCRoomNoDic)
     {
         if (keyValuePair.Value == null)
         {
             return(false);
         }
         if (keyValuePair.Value.NexonID == targetUser.NexonID)
         {
             this.PCRoomNoDic.Remove(keyValuePair.Key, targetUser);
             this.BroadCastUpdate(keyValuePair.Key, this.PCRoomNoDic[keyValuePair.Key].Count);
             return(true);
         }
     }
     return(false);
 }
Example #4
0
 private void Kick_User(CafeAuth target)
 {
     if (target == null || target.FrontendConn == null)
     {
         return;
     }
     target.FrontendConn.RequestOperation(new DisconnectClient());
 }
Example #5
0
        private void connection_RetryLoginRequested(string nxID)
        {
            CafeAuth entity = null;

            if (this.NxIDToEntityDic.TryGetValue(nxID, out entity))
            {
                this.TryLogin(entity);
            }
        }
Example #6
0
        public bool RemoveUser(int pcRoomNo, CafeAuth user)
        {
            if (pcRoomNo <= 0 || user == null)
            {
                return(false);
            }
            if (!this.PCRoomNoDic.ContainsValue(user))
            {
                return(false);
            }
            if (this.PCRoomNoDic.Remove(pcRoomNo, user))
            {
                Log <CafeAuthService> .Logger.InfoFormat("[PCRoom] AddUser is complete. Total: {0}, After {1}'s Count: {2}", this.TotalEntityCount, pcRoomNo, this.PCRoomNoDic[pcRoomNo].Count);

                this.BroadCastUpdate(pcRoomNo, this.PCRoomNoDic[pcRoomNo].Count);
                return(true);
            }
            Log <CafeAuthService> .Logger.InfoFormat("[PCRoom] RemoveUser is failed. Total: {0}, RoomNo: {1}", this.TotalEntityCount, pcRoomNo);

            return(false);
        }
Example #7
0
        protected override IEntity MakeEntity(long id, string category)
        {
            IEntity entity = base.MakeEntity(id, category);

            entity.Tag    = new CafeAuth(this, entity);
            entity.Using += delegate(object sender, EventArgs <IEntityAdapter> e)
            {
                IEntityAdapter value = e.Value;
                if (entity.Tag == null)
                {
                    return;
                }
                if (value.RemoteCategory == "FrontendServiceCore.FrontendService")
                {
                    CafeAuth cafeAuth = entity.Tag as CafeAuth;
                    if (cafeAuth.FrontendConn != null)
                    {
                        cafeAuth.FrontendConn.Close();
                    }
                    cafeAuth.FrontendConn = this.Connect(entity, new Location(value.RemoteID, value.RemoteCategory));
                }
            };
            entity.Used += delegate(object sender, EventArgs <IEntityAdapter> e)
            {
                IEntityAdapter value = e.Value;
                if (value.RemoteCategory == "FrontendServiceCore.FrontendService" || entity.UseCount == 0)
                {
                    entity.Close();
                    Scheduler.Schedule(this.Thread, Job.Create(delegate
                    {
                        if (!entity.IsClosed)
                        {
                            entity.Close(true);
                        }
                    }), new TimeSpan(0, 0, 30));
                }
            };
            return(entity);
        }
Example #8
0
 internal void AddToWaitQueue(CafeAuth entity)
 {
     this.WaitQueue.Add(entity);
 }