Smack

org.jivesoftware.smackx.packet
Class LastActivity

java.lang.Object
  extended byorg.jivesoftware.smack.packet.Packet
      extended byorg.jivesoftware.smack.packet.IQ
          extended byorg.jivesoftware.smackx.packet.LastActivity

public class LastActivity
extends IQ

A last activity IQ for retrieving information about the last activity associated with a Jabber ID. LastActivity (JEP-012) allows for retrieval of how long a particular user has been idle and the message the specified when doing so. To get the last activity of a user, simple send the LastActivity packet to them, as in the following code example:

 XMPPConnection con = new XMPPConnection("jabber.org");
 con.login("john", "doe");
 LastActivity activity = LastActivity.getLastActivity(con, "xray@jabber.org");
 

Author:
Derek DeMoro

Nested Class Summary
static class LastActivity.Provider
          The IQ Provider for LastActivity.
 
Nested classes inherited from class org.jivesoftware.smack.packet.IQ
IQ.Type
 
Field Summary
 long lastActivity
           
 String message
           
 
Fields inherited from class org.jivesoftware.smack.packet.Packet
ID_NOT_AVAILABLE
 
Constructor Summary
LastActivity()
           
 
Method Summary
 String getChildElementXML()
          Returns the sub-element XML section of the IQ packet, or null if there isn't one.
 long getIdleTime()
          Returns number of seconds that have passed since the user last logged out.
static LastActivity getLastActivity(XMPPConnection con, String jid)
          Retrieve the last activity of a particular jid.
 String getStatusMessage()
          Returns the status message of the last unavailable presence received from the user.
 
Methods inherited from class org.jivesoftware.smack.packet.IQ
getType, setType, toXML
 
Methods inherited from class org.jivesoftware.smack.packet.Packet
addExtension, deleteProperty, getError, getExtension, getExtensions, getExtensionsXML, getFrom, getPacketID, getProperty, getPropertyNames, getTo, removeExtension, setError, setFrom, setPacketID, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setTo
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

lastActivity

public long lastActivity

message

public String message
Constructor Detail

LastActivity

public LastActivity()
Method Detail

getChildElementXML

public String getChildElementXML()
Description copied from class: IQ
Returns the sub-element XML section of the IQ packet, or null if there isn't one. Packet extensions must be included, if any are defined.

Extensions of this class must override this method.

Specified by:
getChildElementXML in class IQ
Returns:
the child element section of the IQ XML.

getIdleTime

public long getIdleTime()
Returns number of seconds that have passed since the user last logged out. If the user is offline, 0 will be returned.

Returns:
the number of seconds that have passed since the user last logged out.

getStatusMessage

public String getStatusMessage()
Returns the status message of the last unavailable presence received from the user.

Returns:
the status message of the last unavailable presence received from the user

getLastActivity

public static LastActivity getLastActivity(XMPPConnection con,
                                           String jid)
                                    throws XMPPException
Retrieve the last activity of a particular jid.

Parameters:
con - the current XMPPConnection.
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 Jive Software.