Package marauroa.common.game

Examples of marauroa.common.game.AccountResult


          client.connect("localhost", PORT);
         
          /*
           * Create an account
           */
      AccountResult account = client.createAccount("testUsername", "password", "email");
      assertTrue("Account creation must not fail", !account.failed());

      assertEquals("testUsername", account.getUsername());
     
      /*
       * Create a character for that account.
       */
      RPObject template = new RPObject();
View Full Code Here


            SimpleClient client = new SimpleClient("client.properties");

            Thread.sleep(Math.abs(rand.nextInt() % 20) * 1000);

            client.connect("localhost", PORT);
            AccountResult resAcc = client.createAccount("testUsername" + i, "password","email");
            assertTrue("Account creation must not fail", !resAcc.failed());

            assertEquals("testUsername" + i, resAcc.getUsername());
            assertEquals(Result.OK_CREATED, resAcc.getResult());

            Thread.sleep(Math.abs(rand.nextInt() % 100) * 1000 + 5000);

            client.login("testUsername" + i, "password");

View Full Code Here

            int i = index++;
            SimpleClient client = new SimpleClient("client.properties");

            client.connect("localhost", PORT);

            AccountResult resAcc = client.createAccount("testUsername" + i, "password", "email");
            assertTrue("Account creation must not fail", !resAcc.failed());
            assertEquals("testUsername" + i, resAcc.getUsername());

            Thread.sleep(Math.abs(new Random().nextInt() % 20) * 1000);

            client.login("testUsername" + i, "password");

View Full Code Here

    netMan.addMessage(msgCA);

    int received = 0;

    AccountResult result = null;

    while (received != 1) {
      Message msg = getMessage(TIMEOUT_EXTENDED);

      switch (msg.getType()) {
        case S2C_INVALIDMESSAGE: {
          result = new AccountResult(Result.FAILED_EXCEPTION, username);
          break;
        }
        /* Account was created */
        case S2C_CREATEACCOUNT_ACK:
          logger.debug("Create account ACK");

          MessageS2CCreateAccountACK msgack = (MessageS2CCreateAccountACK) msg;
          result = new AccountResult(Result.OK_CREATED, msgack.getUsername());

          received++;
          break;

        /* Account was not created. Reason explained on event. */
        case S2C_CREATEACCOUNT_NACK:
          logger.debug("Create account NACK");
          MessageS2CCreateAccountNACK nack = (MessageS2CCreateAccountNACK) msg;
          result = new AccountResult(nack.getResolutionCode(), username);

          received++;
          break;
        default:
          logger.debug("Unexpected method while waiting for confirmation of account creation: " + msg);
View Full Code Here

   * @return a Result indicating if account creation was done successfully or not.
   */
  public AccountResult createAccount(String username, String password, String email, String address) {
    try {
      if (!Boolean.parseBoolean(Configuration.getConfiguration().get("allow_account_creation", "true"))) {
        return new AccountResult(Result.FAILED_CREATE_ON_MAIN_INSTEAD, username);
      }
    } catch (IOException e) {
      logger.error(e, e);
    }

    // check account creation limits
    try {
      if (DAORegister.get().get(AccountDAO.class).isAccountCreationLimitReached(address)) {
        return new AccountResult(Result.FAILED_TOO_MANY, username);
      }
    } catch (SQLException e) {
      logger.error(e, e);
      return new AccountResult(Result.FAILED_EXCEPTION, username);
    } catch (IOException e) {
      logger.error(e, e);
      return new AccountResult(Result.FAILED_EXCEPTION, username);
    }

    // forward the creation request to the game
    return ruleProcessor.createAccount(username, password, email);
  }
View Full Code Here

    DBTransaction transaction = transactionPool.beginWork();
    try {
      if (DAORegister.get().get(AccountDAO.class).hasPlayer(transaction, username)) {
        logger.warn("Account already exist: " + username);
        transactionPool.commit(transaction);
        return new AccountResult(Result.FAILED_PLAYER_EXISTS, username);
      }

      DAORegister.get().get(AccountDAO.class).addPlayer(transaction, username, Hash.hash(password), email);

      transactionPool.commit(transaction);
      return new AccountResult(Result.OK_CREATED, username);
    } catch (SQLException e) {
      transactionPool.rollback(transaction);
      TestHelper.fail();
      return new AccountResult(Result.FAILED_EXCEPTION, username);
    }
  }
View Full Code Here

      /*
       * We request RP Manager to create an account for our player. This
       * will return a <b>result</b> of the operation.
       */
      AccountResult val = rpMan.createAccount(username, pasword, email, address);
      Result result = val.getResult();

      if (result == Result.OK_CREATED) {
        /*
         * If result is OK then the account was created and we notify
         * player about that.
         */
        logger.debug("Account (" + username + ") created.");
        MessageS2CCreateAccountACK msgCreateAccountACK = new MessageS2CCreateAccountACK(
            message.getSocketChannel(), val.getUsername());
        msgCreateAccountACK.setProtocolVersion(message.getProtocolVersion());
        netMan.sendMessage(msgCreateAccountACK);
      } else {
        /*
         * Account creation may also fail. So expose the reasons of the
View Full Code Here

    DBTransaction transaction = transactionPool.beginWork();
    try {
      if (DAORegister.get().get(AccountDAO.class).hasPlayer(transaction, username)) {
        logger.warn("Account already exist: " + username);
        transactionPool.commit(transaction);
        return new AccountResult(Result.FAILED_PLAYER_EXISTS, username);
      }

      DAORegister.get().get(AccountDAO.class).addPlayer(transaction, username, Hash.hash(password), email);

      transactionPool.commit(transaction);
      return new AccountResult(Result.OK_CREATED, username);
    } catch (SQLException e) {
      transactionPool.rollback(transaction);
      TestHelper.fail();
      return new AccountResult(Result.FAILED_EXCEPTION, username);
    }
  }
View Full Code Here

  public void t0_createAccount() throws IOException, TimeoutException,
      InvalidVersionException, BannedAddressException {
    client = new SimpleClient("log4j.properties");
    client.connect("localhost", PORT);
    AccountResult res = client.createAccount("testUsername", "password",
        "email");
    assertTrue("Account creation must not fail", !res.failed());

    assertEquals("testUsername", res.getUsername());

    /*
     * Doing a second time should fail
     */
    AccountResult result = client.createAccount("testUsername", "password",
        "email");
    assertTrue("Second account creation must fail", result.failed());
    client.close();
  }
View Full Code Here

          return;
        }

        try {
          final AccountResult result = client.createAccount(
              accountUsername, password, email);
          if (result.failed()) {
            /*
             * If the account can't be created, show an error
             * message and don't continue.
             */
            progressBar.cancel();
            setEnabled(true);
            JOptionPane.showMessageDialog(owner,
                result.getResult().getText(),
                "Create account failed",
                JOptionPane.ERROR_MESSAGE);
          } else {

            /*
 
View Full Code Here

TOP

Related Classes of marauroa.common.game.AccountResult

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.