/**
   * This method is for answering GameServer question about account authentication on GameServer
   * side.
   *
   * @param key
   * @param gsConnection
   */
  public static synchronized void checkAuth(SessionKey key, GsConnection gsConnection) {
    AionConnection con = accountsOnLS.get(key.accountId);

    if (con != null) {
      if (con.getSessionKey().checkSessionKey(key)) {
        /** account is successful logged in on gs remove it from here */
        accountsOnLS.remove(key.accountId);

        GameServerInfo gsi = gsConnection.getGameServerInfo();
        Account acc = con.getAccount();

        /** Add account to accounts on GameServer list and update accounts last server */
        gsi.addAccountToGameServer(acc);

        acc.setLastServer(gsi.getId());
        getAccountDAO().updateLastServer(acc.getId(), acc.getLastServer());

        /** Send response to GameServer */
        gsConnection.sendPacket(
            new SM_ACCOUNT_AUTH_RESPONSE(
                key.accountId, true, acc.getName(), acc.getAccessLevel(), acc.getMembership()));
      }
    } else {
      gsConnection.sendPacket(
          new SM_ACCOUNT_AUTH_RESPONSE(key.accountId, false, null, (byte) 0, (byte) 0));
    }
  }
  /**
   * Check if reconnecting account may auth.
   *
   * @param accountId id of account
   * @param loginOk loginOk
   * @param reconnectKey reconnect key
   * @param client aion client
   */
  public static synchronized void authReconnectingAccount(
      int accountId, int loginOk, int reconnectKey, AionConnection client) {
    ReconnectingAccount reconnectingAccount = reconnectingAccounts.remove(accountId);

    if (reconnectingAccount != null && reconnectingAccount.getReconnectionKey() == reconnectKey) {
      Account acc = reconnectingAccount.getAccount();

      client.setAccount(acc);
      accountsOnLS.put(acc.getId(), client);
      client.setState(State.AUTHED_LOGIN);
      client.setSessionKey(new SessionKey(client.getAccount()));
      client.sendPacket(new SM_UPDATE_SESSION(client.getSessionKey()));
    } else {
      client.close(/* new SM_UPDATE_SESSION, */ true);
    }
  }