Interface PresenceManager

All Known Implementing Classes:
PresenceManagerImpl

public interface PresenceManager
The presence manager tracks on a global basis who's online. The presence monitor watches and reports on what users are present on the server, and in other jabber domains that it knows about. The presence manager does not know about invisible users (they are invisible).
Author:
Iain Shigeoka
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Sort by online time.
    static final int
    Sort by username.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    canProbePresence(org.xmpp.packet.JID prober, String probee)
    Returns true if the the prober is allowed to see the presence of the probee.
    long
    Returns the number of milliseconds since the user went offline or -1 if such information is not available or if the user is online.
    Returns the status sent by the user in his last unavailable presence or null if the user is online or never set such information.
    org.xmpp.packet.Presence
    Returns the user's current presence, or null if the user is unavailable.
    Collection<org.xmpp.packet.Presence>
    getPresences(String username)
    Returns all presences for the user, or null if the user is unavailable.
    void
    handleProbe(org.xmpp.packet.Presence packet)
    Handle a presence probe sent by a remote server.
    boolean
    Returns the availability of the user.
    void
    probePresence(org.xmpp.packet.JID prober, org.xmpp.packet.JID probee)
    Probes the presence of the given XMPPAddress and attempts to send it to the given user.
    void
    sendUnavailableFromSessions(org.xmpp.packet.JID recipientJID, org.xmpp.packet.JID userJID)
    Sends unavailable presence from all of the user's available resources to the remote user.
    void
    userAvailable(org.xmpp.packet.Presence presence)
    Notification message saying that the sender of the given presence just became available.
    void
    userUnavailable(org.xmpp.packet.Presence presence)
    Notification message saying that the sender of the given presence just became unavailable.
  • Field Details

  • Method Details

    • isAvailable

      boolean isAvailable(User user)

      Returns the availability of the user.

      Parameters:
      user - the user who's availability is in question
      Returns:
      true if the user as available for messaging (1 or more available sessions)
    • getPresence

      org.xmpp.packet.Presence getPresence(User user)
      Returns the user's current presence, or null if the user is unavailable. If the user is connected with more than one session, the user's "most available" presence status is returned.
      Parameters:
      user - the user.
      Returns:
      the user's current presence.
    • getPresences

      Collection<org.xmpp.packet.Presence> getPresences(String username)
      Returns all presences for the user, or null if the user is unavailable.
      Parameters:
      username - the name of the user.
      Returns:
      the Presence packets for all the users's connected sessions.
    • probePresence

      void probePresence(org.xmpp.packet.JID prober, org.xmpp.packet.JID probee)
      Probes the presence of the given XMPPAddress and attempts to send it to the given user. If the user probing the presence is using his bare JID then the probee's presence will be sent to all connected resources of the prober.
      Parameters:
      prober - The user requesting the probe
      probee - The XMPPAddress whos presence we would like sent have have probed
    • handleProbe

      void handleProbe(org.xmpp.packet.Presence packet) throws UnauthorizedException
      Handle a presence probe sent by a remote server. The logic to apply is the following: If the remote user is not in the local user's roster with a subscription state of "From", or "Both", then return a presence stanza of type "error" in response to the presence probe. Otherwise, answer the presence of the local user sessions or the last unavailable presence.
      Parameters:
      packet - the received probe presence from a remote server.
      Throws:
      UnauthorizedException - if the user is not authorised
    • canProbePresence

      boolean canProbePresence(org.xmpp.packet.JID prober, String probee) throws UserNotFoundException
      Returns true if the the prober is allowed to see the presence of the probee.
      Parameters:
      prober - the user that is trying to probe the presence of another user.
      probee - the username of the user that is being probed.
      Returns:
      true if the the prober is allowed to see the presence of the probee.
      Throws:
      UserNotFoundException - If the probee does not exist in the local server or the prober is not present in the roster of the probee.
    • sendUnavailableFromSessions

      void sendUnavailableFromSessions(org.xmpp.packet.JID recipientJID, org.xmpp.packet.JID userJID)
      Sends unavailable presence from all of the user's available resources to the remote user. When a remote user unsubscribes from the presence of a local user then the server should send to the remote user unavailable presence from all of the local user's available resources. Moreover, if the recipient user is a local user then the unavailable presence will be sent to all user resources.
      Parameters:
      recipientJID - JID of the remote user that will receive the unavailable presences.
      userJID - JID of the local user.
    • userAvailable

      void userAvailable(org.xmpp.packet.Presence presence)
      Notification message saying that the sender of the given presence just became available.
      Parameters:
      presence - the presence sent by the available user.
    • userUnavailable

      void userUnavailable(org.xmpp.packet.Presence presence)
      Notification message saying that the sender of the given presence just became unavailable.
      Parameters:
      presence - the presence sent by the unavailable user.
    • getLastPresenceStatus

      String getLastPresenceStatus(User user)
      Returns the status sent by the user in his last unavailable presence or null if the user is online or never set such information.
      Parameters:
      user - the user to return his last status information
      Returns:
      the status sent by the user in his last unavailable presence or null if the user is online or never set such information.
    • getLastActivity

      long getLastActivity(User user)
      Returns the number of milliseconds since the user went offline or -1 if such information is not available or if the user is online.
      Parameters:
      user - the user to return his information.
      Returns:
      the number of milliseconds since the user went offline or -1 if such information is not available or if the user is online.