Package marauroa.server.game.container

Examples of marauroa.server.game.container.PlayerEntry


  public void process(Message message) {
    MessageC2SChooseCharacter msg = (MessageC2SChooseCharacter) message;
    try {
      int clientid = msg.getClientID();

      PlayerEntry entry = playerContainer.get(clientid);

      /*
       * verify event so that we can trust that it comes from our player
       * and that it has completed the login stage.
       */
      if (!isValidEvent(msg, entry, ClientState.LOGIN_COMPLETE)) {
        return;
      }

      /* We set the character in the entry info */
      entry.character = msg.getCharacter();

      PlayerEntry oldEntry = playerContainer.getOldEntry(entry);
      if ((oldEntry != null) && (oldEntry.state == ClientState.GAME_BEGIN)) {
        reownOldEntry(oldEntry, entry);
        return;
      }

View Full Code Here


  public void handleDelayedEvent(RPServerManager rpMan, Object data) {
    LoadCharacterCommand cmd = (LoadCharacterCommand) data;
    RPObject object = cmd.getObject();
    int clientid = cmd.getClientid();

    PlayerEntry entry = playerContainer.get(clientid);
    if (entry == null) {
      return;
    }

    // does the character exist and belong to the user?
View Full Code Here

  public void process(Message message) {
    MessageC2SLogout msg = (MessageC2SLogout) message;
    try {
      int clientid = msg.getClientID();

      PlayerEntry entry = playerContainer.get(clientid);

      /*
       * Verify event so that we can trust that it comes from our player
       * and that it has completed the login stage.
       */
      if (!isValidEvent(msg, entry, ClientState.LOGIN_COMPLETE, ClientState.GAME_BEGIN)) {
        return;
      }

      RPObject object = entry.object;

      boolean shouldLogout = true;

      /*
       * We request to logout of game to RP Manager If may be successful or
       * fail and we keep on game.
       */
      if (entry.state == ClientState.GAME_BEGIN) {
        playerContainer.getLock().requestWriteLock();
        if (rpMan.onExit(object)) {
          /* NOTE: Set the Object so that it is stored in Database */
          entry.storeRPObject(object);
        } else {
          /*
           * If RPManager returned false, that means that logout is
           * not allowed right now, so player request is rejected.
           * This can be useful to disallow logout on some situations.
View Full Code Here

  public void process(Message message) {
    MessageC2STransferACK msg = (MessageC2STransferACK) message;
    try {
      int clientid = msg.getClientID();

      PlayerEntry entry = playerContainer.get(clientid);

      // verify event
      if (!isValidEvent(msg, entry, ClientState.GAME_BEGIN)) {
        return;
      }

      /*
       * Handle Transfer ACK here. We iterate over the contents and send
       * them to client for those of them which client told us ACK.
       */
      for (TransferContent content : msg.getContents()) {
        TransferContent contentToTransfer = entry.getContent(content.name);
        if (content.ack == true) {
          logger.debug("Trying transfer content " + content);

          /*
           * We get the content from those of that this client are
           * waiting for being sent to it.
           */
          if (contentToTransfer != null) {
            stats.add("Transfer content", 1);
            stats.add("Tranfer content size", contentToTransfer.data.length);

            logger.debug("Transfering content " + contentToTransfer);

            MessageS2CTransfer msgTransfer = new MessageS2CTransfer(entry.channel,
                contentToTransfer);
            msgTransfer.setClientID(clientid);
            msgTransfer.setProtocolVersion(msg.getProtocolVersion());
            netMan.sendMessage(msgTransfer);
          } else {
            logger.warn("Cannot transfer content (" + content.name
                    + ") because it is null");
          }
        } else {
          stats.add("Transfer content cache", 1);
        }

        if (contentToTransfer != null) {
          entry.removeContent(contentToTransfer);
        }
      }
    } catch (Exception e) {
      logger.error("error while processing TransferACK", e);
    }
View Full Code Here

   *            the final message the contains the encrypted password.
   */
  @Override
  public void process(Message msg) {
      int clientid = msg.getClientID();
      PlayerEntry entry = playerContainer.get(clientid);
     
      // verify event
      if (!isValidEvent(msg, entry, ClientState.CONNECTION_ACCEPTED)) {
        return;
      }
View Full Code Here

          msg.getSocketChannel(), msg.getProtocolVersion());
      DBCommandQueue.get().enqueue(command);
  }

  private void completeLogin(SocketChannel channel, int clientid, int protocolVersion, SecuredLoginInfo info, List<String> previousLogins) {
    PlayerEntry entry = PlayerEntryContainer.getContainer().get(clientid);
    logger.debug("Correct username/password");
    if (entry == null) {
      logger.warn("Did not find PlayerEntry in completeLogin, timeout? " + info);
      return;
    }
View Full Code Here

      }

      //add to nameList
      nameList.put(pName, cid);

      PlayerEntry entry = PlayerEntryContainer.getContainer().get(player);
      if (entry == null) {
        // already logged out again
        return;
      }
      InetAddress inetAddress = entry.getAddress();
      if (inetAddress == null) {
        logger.error("inetAddress of entry " + entry + " is null", new Throwable());
        return;
      }
      String address = inetAddress.getHostAddress();
View Full Code Here

    try {
      // see processLogoutEvent in
      // marauroa-1.34/src/marauroa/server/game/GameServerManager.java

      final PlayerEntryContainer playerContainer = PlayerEntryContainer.getContainer();
      final PlayerEntry entry = playerContainer.get(args.get(0));
      if (entry == null) {
        admin.sendPrivateText(args.get(0) + " not found");
        return;
      }
View Full Code Here

TOP

Related Classes of marauroa.server.game.container.PlayerEntry

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.