private void VerifyLogin(byte[] initialBuffer)
        {
            LoginPacket lp = (LoginPacket) ReadPacket(new LoginPacket(), initialBuffer);
            AccountDAO l = new AccountDAO(Server.ServerInstance.Database);

            if (l.VerifyLogin(lp.Username, lp.Password))
            {
                Tuple<bool, bool> banStatus = l.BanStatus(lp.Username);
                if (banStatus.Item1)
                {
                    SendPacket(banStatus.Item2
                                   ? new LoginFailPacket(PermaBannedMessage)
                                   : new LoginFailPacket(TempBannedMessage));
                    return;
                }

                if (AuthQueue.Add(lp.Username, _sessionId))
                {
                    SendPacket(new LoginOkPacket(_sessionId));
                }
                else
                {
                    SendPacket(new LoginFailPacket(AlreadyLoggedInMessage));
                }
            }
            else
            {
                SendPacket(new LoginFailPacket(WrongPasswordMessage));
            }
            Disconnect("Completed");
        }
 internal Character CreateNewCharacter(CharacterCreatePacket characterCreatePacket, string accountUsername)
 {
     AccountDAO accMgr = new AccountDAO(Server.ServerInstance.Database);
     int accountID = accMgr.GetAccountID(accountUsername);
     if (GetCharactersByAccount(accountID).Length >= 4)
         // Se necessario, possiamo creare due classi che ereditano da Exception per queste due eccezioni invece di usare SqlAlreadyFilledException.
         throw new SqlAlreadyFilledException(
             "This account already have four characters. Is not allowed another character.");
     if (GetCharacter(characterCreatePacket.CharacterName) != null)
         throw new SqlAlreadyFilledException("A character with this name already exists!");
     MySqlDataReader writer = // OK LOL!!!
         _conn.Query(
             string.Format("INSERT INTO `character` (`name`, `race`, `account_id`) VALUES ('{0}', {1}, {2})",
                           characterCreatePacket.CharacterName, characterCreatePacket.SexRace, accountID));
     // TODO: Add CharacterPosition (account-relative) & Look to character table.
     // TODO: Set all values for the record and so call GetCharacter(uint) to get a Character's instance and return...
     writer.Close();
     return null;
 }
 internal Character[] GetCharactersByAccount(string username)
 {
     AccountDAO accMgr = new AccountDAO(Server.ServerInstance.Database);
     int accountID = accMgr.GetAccountID(username);
     return GetCharactersByAccount(accountID);
 }