public final class LastActivityManager extends ExtensionManager
This class also takes care about the following use case, by automatically appending last activity information to 'away' and 'xa' presences:It is often helpful to know the time of the last activity associated with a entity. The canonical usage is to discover when a disconnected user last accessed its server. The 'jabber:iq:last' namespace provides a method for retrieving that information. The 'jabber:iq:last' namespace can also be used to discover or publicize when a connected user was last active on the server (i.e., the user's idle time) or to query servers and components about their current uptime.
When a client automatically sets the user's
<show/>value to "away" or "xa" (extended away), it can indicate when that particular was last active during the current presence session.
By default last activity for the connected resource is updated whenever a message or available non-away, non-xa presence is sent. This strategy of determining last activity can be changed by setting another strategy, e.g. a strategy which determines last activity by idle mouse activity.
Automatic inclusion of last activity information in presence stanzas and support for this protocol can be ExtensionManager.setEnabled(boolean) enabled or disabled}.
LastActivityManager lastActivityManager = xmppSession.getManager(LastActivityManager.class);
LastActivity lastActivity = lastActivityManager.getLastActivity(Jid.valueOf("juliet@example.com/balcony"));
| Modifier and Type | Method and Description |
|---|---|
LastActivity |
getLastActivity(Jid jid)
Gets the last activity of the specified user.
|
LastActivityStrategy |
getLastActivityStrategy()
Gets the currently used strategy to determine last activity of a client.
|
void |
setLastActivityStrategy(LastActivityStrategy lastActivityStrategy)
Sets a strategy, which is used to determine last activity of a client.
|
isEnabled, setEnabledpublic LastActivity getLastActivity(Jid jid) throws XmppException
The information contained in an IQ reply for this namespace is inherently ambiguous. Specifically, for a bare JID
<localpart@domain.tld>the information is the time since the JID was last connected to its server; for a full JID<localpart@domain.tld/resource>the information is the time since the resource was last active in the context of an existing session; and for a bare domain the information is the uptime for the server or component. An application MUST take these differences into account when presenting the information to a human user (if any).
jid - The JID for which the last activity is requested.StanzaException - If the entity returned a stanza error.NoResponseException - If the entity did not respond.XmppExceptionpublic LastActivityStrategy getLastActivityStrategy()
setLastActivityStrategy(LastActivityStrategy)public void setLastActivityStrategy(LastActivityStrategy lastActivityStrategy)
lastActivityStrategy - The strategy.getLastActivityStrategy()Copyright © 2014–2015 XMPP.rocks. All rights reserved.