public final class LastActivityManager extends Manager
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 stanza 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(Jid jid)
Returns the last activity of a particular jid.
|
boolean |
isLastActivitySupported(Jid 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, getAuthenticatedConnectionOrThrow, schedule
public static void setEnabledPerDefault(boolean enabledPerDefault)
enabledPerDefault
- public static LastActivityManager getInstanceFor(XMPPConnection connection)
public void enable()
public void disable()
public LastActivity getLastActivity(Jid jid) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException
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
InterruptedException
public boolean isLastActivitySupported(Jid jid) throws SmackException.NoResponseException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException
jid
- a JID to be tested for Last Activity supportSmackException.NotConnectedException
XMPPException.XMPPErrorException
SmackException.NoResponseException
InterruptedException