Handling User Events

User events allow you to keep track of who are currently connected to the environment's network. The icc.net.IDCard class provides additional functionality to help you in storing and maintaining a hashtable of current users.

a. Initialization of the hashtable This hashtable is automatically initialized empty. However, upon requesting the current users (AllUsers) from the mediator service, the resulting hashtable can be used instead, as follows:
    IDCard.set((Hashtable) request.result()); See here for more information on how to handle requests and their results, and on the mediator service requests in particular.

b. Updating the hashtable The source of a user event is always the user. The following method handles all user events and updates the hashtable accordingly:

public void handleUserEvent(Event event) {
    switch (event.type) {
    case Event.ENTERS:
	event.source.put();
	break;
    case Event.LEAVES:
	event.source.remove();
	break;
    }
}
c. Retrieving address cards The following statement retrieves a user's address card, given the username:
    IDCard card = IDCard.get(username);


Last modified on 5 May 1999 by Rudi Stouffs

This website has been archived and is no longer maintained.