Package rocks.xmpp.extensions.idle.model
Class Idle
- java.lang.Object
-
- rocks.xmpp.extensions.idle.model.Idle
-
public final class Idle extends Object
The implementation of the<idle/>
element in theurn:xmpp:idle:1
namespace.It also provides a convenient method, which gets the idle time from a presence with respect to XEP-0319: Last User Interaction in Presence and the superseded XEP-0256: Last Activity in Presence.
Adding Last User Interaction to Presence
presence.addExtension(Idle.since(OffsetDateTime.now()));
Getting Last User Interaction from Presence
The following method takes the very similar XEP-0256: Last Activity in Presence extension into account as well. Delayed Delivery information on the presence is respected, too.
Instant idleSince = Idle.timeFromPresence(presence);
This class is immutable.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description OffsetDateTime
getSince()
Gets the date/time since the entity is idle.static Idle
since(OffsetDateTime since)
Creates an idle element with the date since when the user is idle.static Instant
timeFromPresence(Presence presence)
Extracts the idle time from a presence.String
toString()
-
-
-
Field Detail
-
NAMESPACE
public static final String NAMESPACE
urn:xmpp:idle:1- See Also:
- Constant Field Values
-
-
Method Detail
-
since
public static Idle since(OffsetDateTime since)
Creates an idle element with the date since when the user is idle.- Parameters:
since
- The date.- Returns:
- The idle element.
-
timeFromPresence
public static Instant timeFromPresence(Presence presence)
Extracts the idle time from a presence.This methods first checks for a XEP-0319: Last User Interaction in Presence extension and uses XEP-0256: Last Activity in Presence semantics as fallback to determine the idle time.
Delayed delivery information is respected.
- Parameters:
presence
- The presence.- Returns:
- The idle time or null if the presence contains no idle information.
-
getSince
public final OffsetDateTime getSince()
Gets the date/time since the entity is idle.- Returns:
- The date/time since the entity is idle.
-
-