/** * 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); }