Package marauroa.common.net.message

Examples of marauroa.common.net.message.MessageC2SCreateCharacter


   *             if timeout happens while waiting for the message.
   * @throws BannedAddressException
   */
  public synchronized CharacterResult createCharacter(String character, RPObject template)
          throws TimeoutException, InvalidVersionException, BannedAddressException {
    Message msgCA = new MessageC2SCreateCharacter(null, character, template);

    netMan.addMessage(msgCA);

    int received = 0;

View Full Code Here


      int clientid = message.getClientID();
      int protocolVersion = message.getProtocolVersion();
      SocketChannel channel = message.getSocketChannel();

      if (message instanceof MessageC2SCreateCharacter) {
        MessageC2SCreateCharacter msg = (MessageC2SCreateCharacter) message;

        RPObject template = msg.getTemplate();
        String character = msg.getCharacter();

        PlayerEntry entry = playerContainer.get(clientid);
        String address = msg.getAddress().getHostAddress();

        // verify event
        if (!isValidEvent(msg, entry, ClientState.LOGIN_COMPLETE)) {
          logger.warn("invalid create character event (client unknown, not logged in or wrong ip-address)");
          return;
        }
        int maxNumberOfCharacters = Configuration.getConfiguration().getInt("limit_characters_per_account", Integer.MAX_VALUE);
        if (entry.characterCounter >= maxNumberOfCharacters) {
          Result result = Result.FAILED_TOO_MANY;
          MessageS2CCreateCharacterNACK msgCreateCharacterNACK = new MessageS2CCreateCharacterNACK(channel, result);
          msgCreateCharacterNACK.setClientID(clientid);
          msgCreateCharacterNACK.setProtocolVersion(protocolVersion);
          netMan.sendMessage(msgCreateCharacterNACK);
          return;
        }

        createCharacter(entry.username, character, template, clientid, address, channel,
            protocolVersion, true);

      } else {
        MessageP2SCreateCharacter msg = (MessageP2SCreateCharacter) message;

        RPObject template = msg.getTemplate();
        String character = msg.getCharacter();
        String address = msg.getForwardedFor();

        if ((msg.getCredentials() != null)
            && (msg.getCredentials().equals(Configuration.getConfiguration().get(
                "proxy_credentials")))) {
          createCharacter(msg.getUsername(), character, template, clientid, address,
              channel, protocolVersion, false);
        } else {
          logger.warn("Invalid credentials for proxy method.");
        }
      }
View Full Code Here

TOP

Related Classes of marauroa.common.net.message.MessageC2SCreateCharacter

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.