Package marauroa.server.game.container

Examples of marauroa.server.game.container.PlayerEntry


    synchronized (contentsToTransfer) {
      for (Map.Entry<RPObject, List<TransferContent>> val : contentsToTransfer.entrySet()) {
        RPObject target = val.getKey();
        List<TransferContent> content = val.getValue();

        PlayerEntry entry = playerContainer.get(target);
        if(entry==null) {
          logger.warn("Entry for player ("+target+") does not exist: " + playerContainer, new Throwable());
          continue;
        }


        if (content == null) {
          logger.warn("content is null");
        }
        if (!entry.contentToTransfer.isEmpty()) {
          // prevent DoS if the client never confirms the Transfer offer
          if (entry.contentToTransfer.size() > 30) {
            synchronized (entry.contentToTransfer) {
              for (int i = 0; i < 10; i++) {
                entry.contentToTransfer.remove(0);
              }
            }
          }
          logger.warn("Adding to existing contentToTransfer for player " + entry.character + " old: " + entry.contentToTransfer + " added " + content);
        }
        entry.contentToTransfer.addAll(content);

        MessageS2CTransferREQ mes = new MessageS2CTransferREQ(entry.channel, content);
        mes.setClientID(entry.clientid);
        mes.setProtocolVersion(entry.getProtocolVersion());

        netMan.sendMessage(mes);
      }

      contentsToTransfer.clear();
View Full Code Here


   *
   * @param object
   *            the player object that we want to disconnect from world
   */
  public void disconnectPlayer(RPObject object) {
    PlayerEntry entry = playerContainer.get(object);
    if (entry == null) {
      /*
       * There is no player entry for such channel This is not necesaryly
       * an error, as the connection could be anything else but an arianne
       * client or we are just disconnecting a player that logout
View Full Code Here

    if (object.has("#clientid")) {
      /*
       * So if object has the attribute, we request a sync perception as
       * we have entered a new zone.
       */
      PlayerEntry entry = playerContainer.get(object);
      if (entry != null) {
        entry.requestSync();
      }
    }
  }
View Full Code Here

  public void handleDelayedEvent(RPServerManager rpMan, Object data) {
    SocketChannel channel = (SocketChannel) data;

    playerContainer.getLock().requestWriteLock();

    PlayerEntry entry = playerContainer.get(channel);
    if (entry != null) {
      /*
       * First we remove the entry from the player container.
       * null means it was already removed by another thread.
       */
      if (playerContainer.remove(entry.clientid) == null) {
        return;
      }

      /*
       * If client is still loging in, don't notify RP as it knows nothing about
       * this client. That means state != of GAME_BEGIN
       */
      if (entry.state == ClientState.GAME_BEGIN) {
        /*
         * If client was playing the game request the RP to disconnected it.
         */
        try {
          rpMan.onTimeout(entry.object);
          entry.storeRPObject(entry.object);
        } catch (Exception e) {
          logger.error("Error disconnecting player" + entry, e);
        }
      }

View Full Code Here

  @Override
  public void process(Message message) {
    MessageC2SKeepAlive alive = (MessageC2SKeepAlive) message;
    try {
      int clientid = alive.getClientID();
      PlayerEntry entry = playerContainer.get(clientid);

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

      entry.update();
    } catch (Exception e) {
      logger.error("error while processing Keep Alive event", e);
    }
  }
View Full Code Here

       * resources but doing nothing useful at all.
       */
      if (playerContainer.size() >= maxNumberOfPlayers) {
        logger.info("Server is full, making room now");
        /* Let's try to make some room for more players. */
        PlayerEntry candidate = playerContainer.getIdleEntry();

        if (candidate != null) {
          /*
           * Cool!, we got a candidate, so we remove and disconnect
           * it.
           */
          netMan.disconnectClient(candidate.channel);

          /*
           * HACK: Remove the entry now so we can continue.
           */       
          playerContainer.remove(candidate.clientid);
        }
      }

      /*
       * We give a new try to see if we can create a entry for this
       * player.
       */
      if (playerContainer.size() >= maxNumberOfPlayers) {
        /* Error: Too many clients logged on the server. */
        logger.warn("Server is full, Client(" + msg.getAddress().toString()
                + ") can't login. You may want to increase max_number_of_players in your server.init. Current value is: " + maxNumberOfPlayers);

        /* Notify player of the event. */
        MessageS2CLoginNACK msgLoginNACK = new MessageS2CLoginNACK(msg.getSocketChannel(),
                MessageS2CLoginNACK.Reasons.SERVER_IS_FULL);
        msgLoginNACK.setProtocolVersion(msg.getProtocolVersion());
        netMan.sendMessage(msgLoginNACK);
        return;
      }

      MessageC2SLoginSendPromise msgLoginSendPromise = (MessageC2SLoginSendPromise) msg;

      PlayerEntry entry = playerContainer.add(msgLoginSendPromise.getSocketChannel());
      entry.setProtocolVersion(msg.getProtocolVersion());

      byte[] serverNonce = Hash.random(Hash.hashLength());
      byte[] clientNonceHash = msgLoginSendPromise.getHash();

      entry.loginInformations = new PlayerEntry.SecuredLoginInfo(key, clientNonceHash,
View Full Code Here

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

      PlayerEntry entry = playerContainer.get(clientid);

      /*
       * verify event
       */
      if (!isValidEvent(msg, entry, ClientState.GAME_BEGIN)) {
        return;
      }
     
      /*
       * Update timeout timestamp on player.
       */
      entry.update();

      /* Send the action to RP Manager */
      RPAction action = msg.getRPAction();

      /*
 
View Full Code Here

  public void handleDelayedEvent(RPServerManager rpMan, Object data) {
    LoadAllActiveCharactersCommand cmd = (LoadAllActiveCharactersCommand) data;
    Map<String, RPObject> characters = cmd.getCharacters();
    int clientid = cmd.getClientid();
    SocketChannel channel = cmd.getChannel();
    PlayerEntry entry = PlayerEntryContainer.getContainer().get(channel);

    // entry is null if the player has timed out during an extremely very long turn overflow
    if (entry != null) {
      entry.characterCounter = characters.keySet().size();
View Full Code Here

  @Override
  public void process(Message message) {
    MessageC2SOutOfSync msg = (MessageC2SOutOfSync) message;
    try {
      int clientid = msg.getClientID();
      PlayerEntry entry = playerContainer.get(clientid);

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

      /*
       * Notify Player Entry that this player is out of Sync
       */
      entry.requestSync();
    } catch (Exception e) {
      logger.error("error while processing OutOfSyncEvent", e);
    }
  }
View Full Code Here

        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)");
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.