Package org.jivesoftware.openfire.spi
Class PresenceManagerImpl
java.lang.Object
org.jivesoftware.openfire.container.BasicModule
org.jivesoftware.openfire.spi.PresenceManagerImpl
- All Implemented Interfaces:
Module,UserEventListener,PresenceManager,XMPPServerListener
public class PresenceManagerImpl
extends BasicModule
implements PresenceManager, UserEventListener, XMPPServerListener
Simple in memory implementation of the PresenceManager interface.
- Author:
- Iain Shigeoka
-
Field Summary
Fields inherited from interface org.jivesoftware.openfire.PresenceManager
SORT_ONLINE_TIME, SORT_USERNAME -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancanProbePresence(org.xmpp.packet.JID prober, String probee) Returns true if the prober is allowed to see the presence of the probee.longgetLastActivity(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.getLastPresenceStatus(User user) Returns the status sent by the user in his last unavailable presence ornullif the user is online or never set such information.org.xmpp.packet.PresencegetPresence(User user) Returns the user's current presence, ornullif the user is unavailable.Collection<org.xmpp.packet.Presence>getPresences(String username) Returns all presences for the user, ornullif the user is unavailable.voidhandleProbe(org.xmpp.packet.Presence packet) Handle a presence probe sent by a remote server.voidinitialize(XMPPServer server) Initializes the basic module.booleanisAvailable(User user) Returns the availability of the user.voidprobePresence(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.voidsendUnavailableFromSessions(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.voidNotification message indicating that the server has been started.voidNotification message indication that the server is about to be stopped.voidstart()Starts the basic module.voidstop()Stops the basic module.voiduserAvailable(org.xmpp.packet.Presence presence) Notification message saying that the sender of the given presence just became available.voiduserCreated(User user, Map<String, Object> params) A user was created.voiduserDeleting(User user, Map<String, Object> params) A user is being deleted.voiduserModified(User user, Map<String, Object> params) A user's name, email, or an extended property was changed.voiduserUnavailable(org.xmpp.packet.Presence presence) Notification message saying that the sender of the given presence just became unavailable.Methods inherited from class org.jivesoftware.openfire.container.BasicModule
destroy, getName
-
Constructor Details
-
PresenceManagerImpl
public PresenceManagerImpl()
-
-
Method Details
-
isAvailable
Description copied from interface:PresenceManagerReturns the availability of the user.
- Specified by:
isAvailablein interfacePresenceManager- 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
Description copied from interface:PresenceManagerReturns the user's current presence, ornullif 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:
getPresencein interfacePresenceManager- Parameters:
user- the user.- Returns:
- the user's current presence.
-
getPresences
Description copied from interface:PresenceManagerReturns all presences for the user, ornullif the user is unavailable.- Specified by:
getPresencesin interfacePresenceManager- Parameters:
username- the name of the user.- Returns:
- the Presence packets for all the user's connected sessions.
-
getLastPresenceStatus
Description copied from interface:PresenceManagerReturns the status sent by the user in his last unavailable presence ornullif the user is online or never set such information.- Specified by:
getLastPresenceStatusin interfacePresenceManager- Parameters:
user- the user to return his last status information- Returns:
- the status sent by the user in his last unavailable presence or
nullif the user is online or never set such information.
-
getLastActivity
Description copied from interface:PresenceManagerReturns 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:
getLastActivityin interfacePresenceManager- 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:PresenceManagerNotification message saying that the sender of the given presence just became available.- Specified by:
userAvailablein interfacePresenceManager- Parameters:
presence- the presence sent by the available user.
-
handleProbe
Description copied from interface:PresenceManagerHandle 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:
handleProbein interfacePresenceManager- 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:PresenceManagerReturns true if the prober is allowed to see the presence of the probee.- Specified by:
canProbePresencein interfacePresenceManager- 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 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:PresenceManagerProbes 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:
probePresencein interfacePresenceManager- Parameters:
prober- The user requesting the probeprobee- The XMPPAddress whos presence we would like sent have have probed
-
userCreated
Description copied from interface:UserEventListenerA user was created.- Specified by:
userCreatedin interfaceUserEventListener- Parameters:
user- the user.params- event parameters.
-
userDeleting
Description copied from interface:UserEventListenerA user is being deleted.- Specified by:
userDeletingin interfaceUserEventListener- Parameters:
user- the user.params- event parameters.
-
userModified
Description copied from interface:UserEventListenerA user's name, email, or an extended property was changed.- Specified by:
userModifiedin interfaceUserEventListener- Parameters:
user- the user.params- event parameters.
-
initialize
Description copied from class:BasicModuleInitializes the basic module.
Inheriting classes that choose to override this method MUST call this initialize() method before accessing BasicModule resources.
- Specified by:
initializein interfaceModule- Overrides:
initializein classBasicModule- Parameters:
server- the server hosting this module.
-
start
Description copied from class:BasicModuleStarts the basic module.
Inheriting classes that choose to override this method MUST call this start() method before accessing BasicModule resources.
- Specified by:
startin interfaceModule- Overrides:
startin classBasicModule- Throws:
IllegalStateException- If start is called before initialize successfully returns
-
stop
public void stop()Description copied from class:BasicModuleStops the basic module.
Inheriting classes that choose to override this method MUST call this stop() method before accessing BasicModule resources.
- Specified by:
stopin interfaceModule- Overrides:
stopin classBasicModule
-
serverStarted
public void serverStarted()Description copied from interface:XMPPServerListenerNotification 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:
serverStartedin interfaceXMPPServerListener
-
serverStopping
public void serverStopping()Description copied from interface:XMPPServerListenerNotification 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:
serverStoppingin interfaceXMPPServerListener
-