public class LastActivityManager extends Manager
LastActivity (XEP-0012) based on the sending JID's type allows for retrieval of:
XMPPConnection con = new XMPPTCPConnection("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");
Modifier and Type | Method and Description |
---|---|
void |
disable() |
void |
enable() |
static LastActivityManager |
getInstanceFor(XMPPConnection connection) |
LastActivity |
getLastActivity(String jid)
Returns the last activity of a particular jid.
|
boolean |
isLastActivitySupported(String jid)
Returns true if Last Activity (XEP-0012) is supported by a given JID
|
static void |
setEnabledPerDefault(boolean enabledPerDefault)
Enable or disable Last Activity for new XMPPConnections.
|
connection, schedule
public static void setEnabledPerDefault(boolean enabledPerDefault)
enabledPerDefault
- public static LastActivityManager getInstanceFor(XMPPConnection connection)
public void enable()
public void disable()
public LastActivity getLastActivity(String jid) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException
jid
- the JID of the user.XMPPException.XMPPErrorException
- thrown if a server error has occured.SmackException.NoResponseException
- if there was no response from the server.SmackException.NotConnectedException
public boolean isLastActivitySupported(String jid) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException
jid
- a JID to be tested for Last Activity supportSmackException.NotConnectedException
XMPPException.XMPPErrorException
SmackException.NoResponseException