Class PresenceManagerImpl

    • Constructor Detail

      • PresenceManagerImpl

        public PresenceManagerImpl()
    • Method Detail

      • isAvailable

        public boolean isAvailable​(User user)
        Description copied from interface: PresenceManager

        Returns the availability of the user.

        Specified by:
        isAvailable in interface PresenceManager
        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

        public org.xmpp.packet.Presence getPresence​(User user)
        Description copied from interface: PresenceManager
        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.
        Specified by:
        getPresence in interface PresenceManager
        Parameters:
        user - the user.
        Returns:
        the user's current presence.
      • getPresences

        public Collection<org.xmpp.packet.Presence> getPresences​(String username)
        Description copied from interface: PresenceManager
        Returns all presences for the user, or null if the user is unavailable.
        Specified by:
        getPresences in interface PresenceManager
        Parameters:
        username - the name of the user.
        Returns:
        the Presence packets for all the users's connected sessions.
      • getLastPresenceStatus

        public String getLastPresenceStatus​(User user)
        Description copied from interface: PresenceManager
        Returns the status sent by the user in his last unavailable presence or null if the user is online or never set such information.
        Specified by:
        getLastPresenceStatus in interface PresenceManager
        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

        public long getLastActivity​(User user)
        Description copied from interface: PresenceManager
        Returns the number of milliseconds since the user went offline or -1 if such information is not available or if the user is online.
        Specified by:
        getLastActivity in interface PresenceManager
        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.
      • userAvailable

        public void userAvailable​(org.xmpp.packet.Presence presence)
        Description copied from interface: PresenceManager
        Notification message saying that the sender of the given presence just became available.
        Specified by:
        userAvailable in interface PresenceManager
        Parameters:
        presence - the presence sent by the available user.
      • userUnavailable

        public void userUnavailable​(org.xmpp.packet.Presence presence)
        Description copied from interface: PresenceManager
        Notification message saying that the sender of the given presence just became unavailable.
        Specified by:
        userUnavailable in interface PresenceManager
        Parameters:
        presence - the presence sent by the unavailable user.
      • handleProbe

        public void handleProbe​(org.xmpp.packet.Presence packet)
                         throws UnauthorizedException
        Description copied from interface: PresenceManager
        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.
        Specified by:
        handleProbe in interface PresenceManager
        Parameters:
        packet - the received probe presence from a remote server.
        Throws:
        UnauthorizedException - if the user is not authorised
      • canProbePresence

        public boolean canProbePresence​(org.xmpp.packet.JID prober,
                                        String probee)
                                 throws UserNotFoundException
        Description copied from interface: PresenceManager
        Returns true if the the prober is allowed to see the presence of the probee.
        Specified by:
        canProbePresence in interface PresenceManager
        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.
      • probePresence

        public void probePresence​(org.xmpp.packet.JID prober,
                                  org.xmpp.packet.JID probee)
        Description copied from interface: PresenceManager
        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.
        Specified by:
        probePresence in interface PresenceManager
        Parameters:
        prober - The user requesting the probe
        probee - The XMPPAddress whos presence we would like sent have have probed
      • sendUnavailableFromSessions

        public void sendUnavailableFromSessions​(org.xmpp.packet.JID recipientJID,
                                                org.xmpp.packet.JID userJID)
        Description copied from interface: PresenceManager
        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.
        Specified by:
        sendUnavailableFromSessions in interface PresenceManager
        Parameters:
        recipientJID - JID of the remote user that will receive the unavailable presences.
        userJID - JID of the local user.
      • initialize

        public void initialize​(XMPPServer server)
        Description copied from class: BasicModule

        Initializes the basic module.

        Inheriting classes that choose to override this method MUST call this initialize() method before accessing BasicModule resources.

        Specified by:
        initialize in interface Module
        Overrides:
        initialize in class BasicModule
        Parameters:
        server - the server hosting this module.
      • start

        public void start()
                   throws IllegalStateException
        Description copied from class: BasicModule

        Starts the basic module.

        Inheriting classes that choose to override this method MUST call this start() method before accessing BasicModule resources.

        Specified by:
        start in interface Module
        Overrides:
        start in class BasicModule
        Throws:
        IllegalStateException - If start is called before initialize successfully returns
      • stop

        public void stop()
        Description copied from class: BasicModule

        Stops the basic module.

        Inheriting classes that choose to override this method MUST call this stop() method before accessing BasicModule resources.

        Specified by:
        stop in interface Module
        Overrides:
        stop in class BasicModule
      • serverStarted

        public void serverStarted()
        Description copied from interface: XMPPServerListener
        Notification message indicating that the server has been started. At this point all server modules have been initialized and started. Message sending and receiving is now possible. However, some plugins may still be pending to be loaded.
        Specified by:
        serverStarted in interface XMPPServerListener
      • serverStopping

        public void serverStopping()
        Description copied from interface: XMPPServerListener
        Notification message indication that the server is about to be stopped. At this point all modules are still running so all services are still available.
        Specified by:
        serverStopping in interface XMPPServerListener