/**
  * Sets the room this player is currently in. If the room given is null, marks the player as not
  * in any room.
  *
  * <p>
  *
  * @param room the room this player should be in, or {@code null}
  */
 protected void setRoom(SwordWorldRoom room) {
   DataManager dataManager = AppContext.getDataManager();
   dataManager.markForUpdate(this);
   if (room == null) {
     currentRoomRef = null;
     return;
   }
   currentRoomRef = dataManager.createReference(room);
 }
Пример #2
0
  /**
   * Sets the current <code>UserID</code> for this <code>Player</code>, which changes from session
   * to session. Typically this is called when the player first logs again, and not again until the
   * player logs out and logs back in.
   *
   * @param uid the player's user identifier
   */
  public void setCurrentSession(ClientSession session) {
    DataManager dataMgr = AppContext.getDataManager();
    dataMgr.markForUpdate(this);
    currentSessionRef = dataMgr.createReference(session);

    // Also inform the client of the session ID
    // FIXME, this is hacked in as the only non-channel message
    // for ease of porting -JM
    BigInteger sid = currentSessionRef.getId();
    byte[] bytes = sid.toByteArray();
    session.send(ByteBuffer.wrap(bytes));
  }
Пример #3
0
 /**
  * Called when the player joins a channel. In this system, the player only joins a new channel in
  * the context of joining a new game, and the player is never on more than one channel.
  *
  * @param cid the new channel
  */
 public void userJoinedChannel(UtilChannel newChannel) {
   DataManager dataManager = AppContext.getDataManager();
   dataManager.markForUpdate(this);
   channelRef = dataManager.createReference(newChannel);
 }
 public void incrementNumber(DataManager dataManager) {
   dataManager.markForUpdate(this);
   number++;
 }
 /**
  * Mark this player as logged in on the given session.
  *
  * @param session the session this player is logged in on
  */
 protected void setSession(ClientSession session) {
   DataManager dataMgr = AppContext.getDataManager();
   dataMgr.markForUpdate(this);
   currentSessionRef = dataMgr.createReference(session);
   logger.log(Level.INFO, "Set session for {0} to {1}", new Object[] {this, session});
 }