Ejemplo n.º 1
0
  public boolean removePlayer(RocketPlayer player) {
    logger.log(Level.INFO, "{0} leaves {1}", new Object[] {player.getName(), this.getName()});

    AppContext.getDataManager().markForUpdate(this);
    Channel tableChannel = tableChannelRef.getForUpdate();
    tableChannel.leave(player.getClientSessionRef().get());

    // The reference created below should be identical to one of the players
    // on our table. I think createReference has some clever logic to
    // not create another reference if one already exists.
    ManagedReference<RocketPlayer> playerRef = AppContext.getDataManager().createReference(player);

    if (playerRef.equals(player1Ref)) {
      player1Ref = null;
    } else if (playerRef.equals(player2Ref)) {
      player2Ref = null;
    } else if (playerRef.equals(player3Ref)) {
      player3Ref = null;
    } else if (playerRef.equals(player4Ref)) {
      player4Ref = null;
    } else {
      logger.log(
          Level.SEVERE, "player " + player.getName() + " doesn't appear to be one of this table!");
      return false;
    }

    setTableAvailable(true);
    maybeChangeStatusOnRemovePlayer();
    return true;
  }
Ejemplo n.º 2
0
 /** {@inheritDoc} */
 @Override
 public boolean equals(Object object) {
   if (object == this) {
     return true;
   } else if (object instanceof ClientSessionWrapper) {
     return sessionRef.equals(((ClientSessionWrapper) object).sessionRef);
   } else {
     return false;
   }
 }