Beispiel #1
0
        public static void HeartPulse(GameUser user)
        {
            UserData userData;
            if (_users.TryGetValue(user.UserNo, out userData) == false)
                return;

            userData._heartPulse.Restart();
        }
Beispiel #2
0
        public Item(GameUser user, Int32 itemId, Int32 itemNo)
        {
            _user = user;
            Base = ItemBook.Data.Items.Find(v => v.ItemId == itemId);
            if (Base == null)
                throw new AegisException("Invalid itemId={0}.", itemId);

            ItemNo = itemNo;
            PromotionId = 0;
            Quantity = Base.ItemCount;
        }
Beispiel #3
0
        public Character(GameUser user, Int32 characterId, Int32 characterNo)
        {
            _user = user;
            Base = CharacterBook.Find(characterId);

            CharacterNo = characterNo;
            Level = 1;
            Exp = 0;

            GradeId = Base.InitGradeId;
            PromotionId = Base.InitPromotionId;
        }
Beispiel #4
0
        public static void Login(Int32 userNo, Int32 authKey, Action<GameUser, Int32> actionOnComplete)
        {
            GameUser user = Find(userNo);
            if (user != null)
                Logout(userNo);

            using (DBCommand cmd = AuthDB.NewCommand())
            {
                Int32 dbAuthKey = -1;

                cmd.CommandText.Append($"select authkey from t_accounts where userno={userNo};");
                cmd.PostQuery(() =>
                {
                    if (cmd.Reader.Read())
                        dbAuthKey = cmd.Reader.GetInt32(0);
                },
                (exception) =>
                {
                    if (exception != null)
                    {
                        actionOnComplete(null, ResultCode.Database_Error);
                        Logger.Write(LogType.Err, 2, exception.ToString());
                    }
                    //  인증키 확인
                    else if (dbAuthKey == authKey)
                    {
                        //  유저데이터 및 게임데이터 로드
                        user = new GameUser(userNo);
                        user.LoadFromDB((result) =>
                        {
                            _users.Add(userNo, new UserData(user));
                            actionOnComplete(user, result);
                        });
                    }
                    //  잘못된 인증키
                    else
                        actionOnComplete(null, ResultCode.InvalidAuthKey);
                });
            }
        }
Beispiel #5
0
        private void OnAccepted(Session session)
        {
            //  초기화
            _user = null;

            //  각 8비트마다 0이 나오지 않는 임의 숫자 생성
            Int32 seed = 0;
            seed |= Randomizer.NextNumber(1, 255) << 24;
            seed |= Randomizer.NextNumber(1, 255) << 16;
            seed |= Randomizer.NextNumber(1, 255) << 8;
            seed |= Randomizer.NextNumber(1, 255);

            //  패킷 암호화 키 생성
            {
                String characterSet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz";
                char[] ascii = new char[16];

                for (Int32 i = 0; i < 16; ++i)
                {
                    Int32 val = seed & (0x6E << i);
                    ascii[i] = characterSet[(val % characterSet.Length)];
                }
                _aesIV = new String(ascii);

                for (Int32 i = 0; i < 16; ++i)
                {
                    Int32 val = seed & (0xF4 << i);
                    ascii[i] = characterSet[(val % characterSet.Length)];
                }
                _aesKey = new String(ascii);
            }

            SecurePacket ntfPacket = new SecurePacket(Protocol.GetID("CS_Hello_Ntf"));
            ntfPacket.PutInt32(ResultCode.Ok);
            ntfPacket.PutInt32((Int32)ServerType.GameServer);
            ntfPacket.PutInt32(seed);
            ntfPacket.Encrypt(ServerMain.AES_IV, ServerMain.AES_Key);
            base.SendPacket(ntfPacket);
        }
Beispiel #6
0
 public InvenItem(GameUser user)
 {
     _user = user;
 }
Beispiel #7
0
 public PlayDeck(GameUser user)
 {
     _user = user;
 }
Beispiel #8
0
 public InvenCharacter(GameUser user)
 {
     _user = user;
 }
Beispiel #9
0
 public Resource(GameUser user)
 {
     _user = user;
 }
Beispiel #10
0
 public Energy(GameUser user)
 {
     _user = user;
 }
Beispiel #11
0
            public Data(GameUser user, Int32 energyId, Int32 point, DateTime lastUpdateTime)
            {
                _user = user;
                EnergyId = energyId;

                _point = point;
                LastUpdateTime = lastUpdateTime;
            }
Beispiel #12
0
            public Data(GameUser user, Int32 energyId)
            {
                _user = user;
                EnergyId = energyId;

                _point = PlayerBook.Energy.GetData(_user.Level, EnergyId).MaxPoint;
                LastUpdateTime = DateTime.Now;
            }
Beispiel #13
0
 private void OnClosed(Session session)
 {
     if (_user != null)
         _user.Session = null;
     _user = null;
 }
Beispiel #14
0
        private void OnReceived(Session session, StreamBuffer buffer)
        {
            SecurePacketRequest reqPacket = new SecurePacketRequest(buffer);
            reqPacket.Decrypt(_aesIV, _aesKey);
            reqPacket.SkipHeader();

            Statistics.ReceivedBytes.Add(reqPacket.Size);
            Statistics.ReceivedCount.Add(1);

            try
            {
                if (reqPacket.PacketId == Protocol.GetID("CS_Login_Req"))
                    OnCS_Login_Req(reqPacket);
                else
                {
                    _user = UserManager.Find(reqPacket.UserNo);
                    if (_user == null)
                    {
                        ForceClose("Invalid UserNo.");
                        return;
                    }
                    if (reqPacket.SeqNo != _user.SeqNo + 1)
                    {
                        ForceClose("Invalid Sequence Number.");
                        return;
                    }

                    _user.SeqNo = reqPacket.SeqNo;
                    _user.Session = this;
                    reqPacket.Dispatch(_user, "On" + Protocol.GetName(reqPacket.PacketId));

                    UserManager.HeartPulse(_user);
                }
            }
            catch (AegisException e) when (e.ResultCodeNo == AegisResult.BufferUnderflow)
            {
                Logger.Write(LogType.Err, 2, "Cannot read more data at PacketId(=0x{0:X}).", reqPacket.PacketId);
            }
            catch (Exception e)
            {
                Logger.Write(LogType.Err, 2, e.ToString());
            }
        }
Beispiel #15
0
 public UserData(GameUser user)
 {
     _user = user;
 }