private void process(Presence presence, ClientSession session) throws UnauthorizedException, PacketException {
        try {
            Presence.Type type = presence.getType();
            // Available
            if (type == null) {
                if (session != null && session.getStatus() == Session.Status.CLOSED) {
                    Log.warn("Rejected available presence: " + presence + " - " + session);
                    return;
                }

                if (session != null) {
                    session.setPresence(presence);
                }

                broadcastUpdate(presence.createCopy());

                if (session != null && !session.isInitialized()) {
                    initSession(session);
                    session.setInitialized(true);
                }

                // Notify the presence manager that the user is now available. The manager may
                // remove the last presence status sent by the user when he went offline.
                presenceManager.userAvailable(presence);
            }
            else if (Presence.Type.unavailable == type) {
                if (session != null) {
                    session.setPresence(presence);
                }
                broadcastUpdate(presence.createCopy());
                broadcastUnavailableForDirectedPresences(presence);
                // Notify the presence manager that the user is now unavailable. The manager may
                // save the last presence status sent by the user and keep track when the user
                // went offline.
                presenceManager.userUnavailable(presence);
            }
            else {
                presence = presence.createCopy();
                if (session != null) {
                    presence.setFrom(new JID(null, session.getServerName(), null, true));
                    presence.setTo(session.getAddress());
                }
                else {
                    JID sender = presence.getFrom();
                    presence.setFrom(presence.getTo());
                    presence.setTo(sender);
                }
                presence.setError(PacketError.Condition.bad_request);
                deliverer.deliver(presence);
            }

        }
        catch (Exception e) {
            Log.error(LocaleUtils.getLocalizedString("admin.error") + ". Triggered by packet: " + presence, e);
        }
    }
A map that, for all nodes in the cluster except for the local one, tracks what directed presences a particular
user has sent, as tracked in #directedPresencesCache. Every key of the inner map corresponds to a key in that
cache (which is the JID of the sender of the direct presence). Every String in the collection that is the mapped
value corresponds to the recipient of the DirectedPresence as maintained in the cache.

Whenever any cluster node adds or removes an entry to {@link #directedPresencesCache}, this map, on
<em>every</em> cluster node, will receive a corresponding update. This ensures that every cluster node has a
complete overview of all cache entries (or at least the most important details of each entry - we should avoid
duplicating the entire cache, as that somewhat defaults the purpose of having the cache).

This map is to be used when a cluster node unexpectedly leaves the cluster. As the cache implementation uses a
distributed data structure that gives no guarantee that all data is visible to all cluster nodes at any given
time, the cache cannot be trusted to 'locally' contain all information that was added to it by the disappeared
node (nor can that node be contacted to retrieve the missing data, because it has already disappeared).
xmppserver/src/main/java/org/jivesoftware/openfire/handler/PresenceUpdateHandler.java