RemotePresenceEventDispatcher.remoteUserUnavailable(packet);
}
}
// Check that sender session is still active (let unavailable presence go through)
Session session = sessionManager.getSession(packet.getFrom());
if (session != null && session.getStatus() == Session.STATUS_CLOSED && type == null) {
Log.warn("Rejected available presence: " + packet + " - " + session);
return;
}
// The user sent a directed presence to an entity
// Broadcast it to all connected resources
for (JID jid : routingTable.getRoutes(recipientJID, senderJID)) {
// Register the sent directed presence
updateHandler.directedPresenceSent(packet, jid, recipientJID.toString());
// Route the packet
routingTable.routePacket(jid, packet, false);
}
}
}
else if (Presence.Type.subscribe == type // presence subscriptions
|| Presence.Type.unsubscribe == type
|| Presence.Type.subscribed == type
|| Presence.Type.unsubscribed == type)
{
subscribeHandler.process(packet);
}
else if (Presence.Type.probe == type) {
// Handle a presence probe sent by a remote server
if (!XMPPServer.getInstance().isLocal(recipientJID)) {
routingTable.routePacket(recipientJID, packet, false);
}
else {
// Handle probe to a local user
presenceManager.handleProbe(packet);
}
}
else {
// It's an unknown or ERROR type, just deliver it because there's nothing
// else to do with it
routingTable.routePacket(recipientJID, packet, false);
}
}
catch (Exception e) {
Log.error(LocaleUtils.getLocalizedString("admin.error.routing"), e);
Session session = sessionManager.getSession(packet.getFrom());
if (session != null) {
session.close();
}
}
}