Class PresenceSubscribeHandler
- java.lang.Object
-
- org.jivesoftware.openfire.container.BasicModule
-
- org.jivesoftware.openfire.handler.PresenceSubscribeHandler
-
- All Implemented Interfaces:
ChannelHandler<org.xmpp.packet.Presence>
,Module
public class PresenceSubscribeHandler extends BasicModule implements ChannelHandler<org.xmpp.packet.Presence>
Implements the presence protocol. Clients use this protocol to update presence and roster information.The handler must properly detect the presence type, update the user's roster, and inform presence subscribers of the session's updated presence status. Presence serves many purposes in Jabber so this handler will likely be the most complex of all handlers in the server.
There are four basic types of presence updates:
- Simple presence updates - addressed to the server (or to address), these updates are properly addressed by the server, and multicast to interested subscribers on the user's roster. An empty, missing, or "unavailable" type attribute indicates a simple update (there is no "available" type although it should be accepted by the server.
- Directed presence updates - addressed to particular jabber entities, these presence updates are properly addressed and directly delivered to the entity without broadcast to roster subscribers. Any update type is possible except those reserved for subscription requests.
- Subscription requests - these updates request presence subscription
status changes. Such requests always affect the roster. The server must:
- update the roster with the proper subscriber info
- push the roster changes to the user
- forward the update to the correct parties.
- XMPPServer probes - Provides a mechanism for servers to query the presence status of users on another server. This allows users to immediately know the presence status of users when they come online rather than way for a presence update broadcast from the other server or tracking them as they are received. Requires S2S capabilities.
Warning
There should be a way of determining whether a session has authorization to access this feature. I'm not sure it is a good idea to do authorization in each handler. It would be nice if the framework could assert authorization policies across channels.- Author:
- Iain Shigeoka
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
PresenceSubscribeHandler.Change
Indicate a state change.
-
Constructor Summary
Constructors Constructor Description PresenceSubscribeHandler()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static PresenceSubscribeHandler.Change
getStateChange(RosterItem.SubType itemSubType, org.xmpp.packet.Presence.Type action, boolean isSending)
Determine the changes to apply to the item, according to its subscription state.void
initialize(XMPPServer server)
Initializes the basic module.void
process(org.xmpp.packet.Presence presence)
Process an XMPP packet.-
Methods inherited from class org.jivesoftware.openfire.container.BasicModule
destroy, getName, start, stop
-
-
-
-
Method Detail
-
process
public void process(org.xmpp.packet.Presence presence) throws PacketException
Description copied from interface:ChannelHandler
Process an XMPP packet.- Specified by:
process
in interfaceChannelHandler<org.xmpp.packet.Presence>
- Parameters:
presence
- a packet to process.- Throws:
PacketException
- thrown if the packet is malformed (results in the sender's session being shutdown).
-
getStateChange
public static PresenceSubscribeHandler.Change getStateChange(RosterItem.SubType itemSubType, org.xmpp.packet.Presence.Type action, boolean isSending)
Determine the changes to apply to the item, according to its subscription state. The method also turns the action and sending status into an integer code for easier processing (switch statements).Code relies on states being in numerical order without skipping. In addition, the receive states must parallel the send states so that (send state X) + STATE_RECV_SUBSCRIBE == (receive state X) where X is subscribe, subscribed, etc.
- Parameters:
itemSubType
- The item to be updatedaction
- The new state change requestisSending
- True if the roster owner of the item is sending the new state change request- Returns:
- Change changes to apply to the item
-
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 interfaceModule
- Overrides:
initialize
in classBasicModule
- Parameters:
server
- the server hosting this module.
-
-