/**
   * Start updating the presence information. Tells the PresenceManager to plug into the
   * UserListener system so it can be notified of user join/leave events, which it takes as signals
   * to update the presence information.
   */
  public void startPresenceUpdating() {
    if (!service.isValidConfiguration()) {
      logger.log(
          Level.WARNING,
          "Tried to start presence updating, but XMPP configuration was not valid. Make sure to set an account name and password.");
      return;
    }

    // Start a recurring task that updates the status messages.

    // lets try using the UserManager notification mechanism for deciding when a good time to update
    // would be.
    UserManager manager = UserManager.getUserManager();

    listener = new PresenceUserListener();
    // Using this inner class as an indirection to avoid serialization problems.
    manager.addUserListener(listener);

    // Kick off a task that periodically cleans out expired XMPP connections
    // (ie connections from which we haven't seen an event in a while)
    // no need to run this that often; being off by a few seconds is no big deal.
    AppContext.getTaskManager().schedulePeriodicTask(new ExpireConnectionsTask(), 0, 3000);
  }
  /**
   * Get the Wonderland identity based on the given client id. This requires mapping first to a
   * WonderlandClientID and then to a UserMO
   *
   * @param clientID the client ID as a BigInteger
   * @return the identity associated with that clientID, or null if the client can't be found
   */
  protected WonderlandIdentity getIdentity(BigInteger clientID) {
    // map the provided value to a client ID to check
    SessionMapManager smm = AppContext.getManager(SessionMapManager.class);
    WonderlandClientID checkID = smm.getClientID(clientID);
    if (checkID == null) {
      logger.warning("Unable to find client ID for " + clientID);
      return null;
    }

    // now get a user
    UserMO user = UserManager.getUserManager().getUser(checkID);
    if (user == null) {
      logger.warning("Unable to find user for " + checkID.getID());
      return null;
    }

    return user.getIdentity();
  }
 /** Stops presence updating by removing the listener on login/logout events. */
 public void stopPresenceUpdating() {
   UserManager manager = UserManager.getUserManager();
   manager.removeUserListener(listener);
 }
 public void registered(WonderlandClientSender sender) {
   UserManager.getUserManager().addUserListener(this);
 }