Class 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 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
      • 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.