Package rocks.xmpp.im.subscription
Class PresenceManager
- java.lang.Object
-
- rocks.xmpp.core.session.Manager
-
- rocks.xmpp.im.subscription.PresenceManager
-
public final class PresenceManager extends Manager
Manages subscription requests and presences.This class allows to request, approve, deny and unsubscribe subscriptions.
This class is unconditionally thread-safe.
- See Also:
- 3. Managing Presence Subscriptions
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
approveSubscription(Jid jid)
Approves a subscription request.String
denySubscription(Jid jid)
Cancels a previously granted subscription or denies a subscription request.Presence
getLastSentPresence()
Gets the last sent (non-directed) presence, that has been broadcast by the server.Collection<Presence>
getLastSentPresences()
Gets the last sent presences, that have been sent, including directed presences.Presence
getPresence(Jid jid)
Gets the presence for a given contact.String
requestSubscription(Jid jid, String status)
Sends a subscription request to a potential contact.String
unsubscribe(Jid jid)
Unsubscribes from a contact's presence.-
Methods inherited from class rocks.xmpp.core.session.Manager
isEnabled, setEnabled
-
-
-
-
Method Detail
-
getPresence
public final Presence getPresence(Jid jid)
Gets the presence for a given contact.If the given JID is a bare JID, and the contact has sent multiple presences with different resources, the "best" presence is returned, i.e. the presence with the highest priority or the presence with the "most available"
<show/>
element.If the JID is a full JID, the exact presence of that JID is returned.
If no presence could be found an unavailable presence is returned.
- Parameters:
jid
- The JID.- Returns:
- The presence.
-
requestSubscription
public final String requestSubscription(Jid jid, String status)
Sends a subscription request to a potential contact.- Parameters:
jid
- The contact's JID.status
- The status, which is used for additional information during the subscription request.- Returns:
- The id, which is used for the request.
- See Also:
- 3.1.1. Client Generation of Outbound Subscription Request
-
approveSubscription
public final String approveSubscription(Jid jid)
Approves a subscription request.- Parameters:
jid
- The contact's JID, who has previously requested a subscription.- Returns:
- The id, which is used for the approval.
- See Also:
- 3.1.4. Client Processing of Inbound Subscription Request
-
denySubscription
public final String denySubscription(Jid jid)
Cancels a previously granted subscription or denies a subscription request.This basically means that the contact won't receive presence information from you.
- Parameters:
jid
- The contact's JID, whose subscription is denied or canceled.- Returns:
- The id, which is used for the subscription denial.
- See Also:
- 3.2.1. Client Generation of Subscription Cancellation
-
unsubscribe
public final String unsubscribe(Jid jid)
Unsubscribes from a contact's presence.That basically means, that you will not receive any presence information from the contact anymore.
- Parameters:
jid
- The contact's JID.- Returns:
- The id, which is used for the unsubscription.
- See Also:
- 3.3.1. Client Generation of Unsubscribe
-
getLastSentPresence
public final Presence getLastSentPresence()
Gets the last sent (non-directed) presence, that has been broadcast by the server.- Returns:
- The presence.
-
getLastSentPresences
public final Collection<Presence> getLastSentPresences()
Gets the last sent presences, that have been sent, including directed presences.- Returns:
- The presence.
-
-