Exemplo n.º 1
0
 public void SendAuthenticationResponse(SecretNetworkResponseType response)
 {
     OutMessage.Reset();
     OutMessage.AddByte((byte)SecretNetworkPacketType.Authentication);
     OutMessage.AddByte((byte)response);
     if (response != SecretNetworkResponseType.Success)
     {
         OutMessage.DisconnectAfterMessage = true;
     }
     Send(OutMessage);
 }
Exemplo n.º 2
0
        public void Disconnect(string reason, uint version)
        {
            OutputMessage message = OutputMessagePool.GetOutputMessage(this, false);

            if (version > 1076)
            {
                message.AddByte((byte)ServerPacketType.Disconnect1076);
            }
            else
            {
                message.AddByte((byte)ServerPacketType.Disconnect);
            }
            message.AddString(reason);

            message.DisconnectAfterMessage = true;
            OutputMessagePool.AddToQueue(message);
        }
Exemplo n.º 3
0
        protected virtual void DispatchDisconnect(string reason)
        {
            OutputMessage message = OutputMessagePool.GetOutputMessage(this, false);

            message.AddByte((byte)ServerPacketType.ErrorMessage);
            message.AddString(reason);

            message.DisconnectAfterMessage = true;
            OutputMessagePool.AddToQueue(message);
        }
Exemplo n.º 4
0
        private void HandleLoginPacket(string accountName, byte[] password)
        {
            //TODO: Check IP Ban

            if (string.IsNullOrEmpty(accountName))
            {
                Disconnect("Invalid account name.", Version);
                return;
            }

            byte[] hash           = LoginServer.PasswordHasher.ComputeHash(password);
            string hashedPassword = string.Empty;

            foreach (byte b in hash)
            {
                hashedPassword += b.ToString("x2");
            }

            string       sessionKey;
            AccountModel acc = LoginServerData.RetrieveAccountData(accountName, hashedPassword, out sessionKey);

            if (acc == null)
            {
                Disconnect("Account name or password is not correct.", Version);
                return;
            }

            OutputMessage message = OutputMessagePool.GetOutputMessage(this, false);

            message.AddByte((byte)ServerPacketType.MOTD);
            message.AddString(LoginServer.MOTD);

            message.AddByte((byte)ServerPacketType.SessionKey);
            message.AddString(sessionKey);

            message.AddByte((byte)ServerPacketType.CharacterList);
            message.AddByte((byte)LoginServer.GameWorlds.Count);
            foreach (GameWorldModel world in LoginServer.GameWorlds.Values)
            {
                message.AddByte(world.GameWorldId);
                message.AddString(world.GameWorldName);
                message.AddString(world.GameWorldIP);
                message.AddUInt16(world.GameWorldPort);
                message.AddByte(0);
            }

            message.AddByte((byte)acc.Characters.Count);
            foreach (AccountCharacterModel character in acc.Characters)
            {
                message.AddByte((byte)character.ServerId);
                message.AddString(character.CharacterName);
            }

            if (!acc.PremiumUntil.HasValue)
            {
                message.AddUInt16(0xFFFF);
            }
            else
            {
                TimeSpan premiumLeft = acc.PremiumUntil.Value - DateTime.Now;
                message.AddUInt16((ushort)premiumLeft.TotalDays);
            }

            message.DisconnectAfterMessage = true;
            OutputMessagePool.AddToQueue(message);
        }