Smack

org.jivesoftware.smackx
Class LastActivityManager

java.lang.Object
  extended by org.jivesoftware.smackx.LastActivityManager

public class LastActivityManager
extends Object

A last activity manager for handling information about the last activity associated with a Jabber ID. A manager handles incoming LastActivity requests of existing Connections. It also allows to request last activity information of other users.

LastActivity (JEP-012) based on the sending JID's type allows for retrieval of:

  1. How long a particular user has been idle
  2. How long a particular user has been logged-out and the message the specified when doing so.
  3. How long a host has been up.

For example to get the idle time of a user logged in a resource, simple send the LastActivity packet to them, as in the following code:

 Connection con = new XMPPConnection("jabber.org");
 con.login("john", "doe");
 LastActivity activity = LastActivity.getLastActivity(con, "xray@jabber.org/Smack");
 
To get the lapsed time since the last user logout is the same as above but with out the resource:
 LastActivity activity = LastActivity.getLastActivity(con, "xray@jabber.org");
 
To get the uptime of a host, you simple send the LastActivity packet to it, as in the following code example:

 LastActivity activity = LastActivity.getLastActivity(con, "jabber.org");
 

Author:
Gabriel Guardincerri

Method Summary
static LastActivity getLastActivity(Connection con, String jid)
          Returns the last activity of a particular jid.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getLastActivity

public static LastActivity getLastActivity(Connection con,
                                           String jid)
                                    throws XMPPException
Returns the last activity of a particular jid. If the jid is a full JID (i.e., a JID of the form of 'user@host/resource') then the last activity is the idle time of that connected resource. On the other hand, when the jid is a bare JID (e.g. 'user@host') then the last activity is the lapsed time since the last logout or 0 if the user is currently logged in. Moreover, when the jid is a server or component (e.g., a JID of the form 'host') the last activity is the uptime.

Parameters:
con - the current Connection.
jid - the JID of the user.
Returns:
the LastActivity packet of the jid.
Throws:
XMPPException - thrown if a server error has occured.

Smack

Copyright © 2003-2007 Jive Software.