Commit 8cf086b5 authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gaston

IQ packets sent to a RoutableChannelHandler (includes Components, MUC &...

IQ packets sent to a RoutableChannelHandler (includes Components, MUC & ComponentManager) that is not a ClientSession will receive and must process the IQ packet. Otherwise the previous (old) logic is applied based on the packet's namespace.


git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@967 b35dd754-fafc-0310-a699-88a17e54d16e
parent 1e5c3063
......@@ -20,7 +20,6 @@ import org.jivesoftware.util.Log;
import org.xmpp.packet.IQ;
import org.xmpp.packet.JID;
import org.xmpp.packet.PacketError;
import org.xmpp.component.Component;
import java.util.ArrayList;
import java.util.List;
......@@ -41,7 +40,6 @@ public class IQRouter extends BasicModule {
private List<IQHandler> iqHandlers = new ArrayList<IQHandler>();
private Map<String, IQHandler> namespace2Handlers = new ConcurrentHashMap<String, IQHandler>();
private SessionManager sessionManager;
private InternalComponentManager componentManager;
/**
* Creates a packet router.
......@@ -125,7 +123,6 @@ public class IQRouter extends BasicModule {
routingTable = server.getRoutingTable();
iqHandlers.addAll(server.getIQHandlers());
sessionManager = server.getSessionManager();
componentManager = InternalComponentManager.getInstance();
}
/**
......@@ -143,16 +140,21 @@ public class IQRouter extends BasicModule {
private void handle(IQ packet) {
JID recipientJID = packet.getTo();
try {
// Check for registered components
Component component = null;
// Check for registered components and/or services
if (recipientJID != null) {
component = componentManager.getComponent(packet.getTo().toBareJID());
}
if (component != null) {
// A component was found that can handle the Packet
component.processPacket(packet);
try {
RoutableChannelHandler serviceRoute = routingTable.getRoute(recipientJID);
if (!(serviceRoute instanceof ClientSession)) {
// A component/service was found that can handle the Packet
serviceRoute.process(packet);
return;
}
}
catch (NoSuchRouteException e) {
// Do nothing. Continue looking for a handler
}
}
else if (isLocalServer(recipientJID)) {
if (isLocalServer(recipientJID)) {
// Let the server handle the Packet
Element childElement = packet.getChildElement();
String namespace = null;
......@@ -178,19 +180,6 @@ public class IQRouter extends BasicModule {
}
else {
// JID is of the form <node@domain>
try {
// Let a "service" handle this packet otherwise return an error
// Useful for MUC where node refers to a room and domain is the
// MUC service.
ChannelHandler route = routingTable.getRoute(recipientJID);
if (route instanceof BasicModule) {
route.process(packet);
return;
}
}
catch (NoSuchRouteException e) {
// do nothing
}
// Answer an error since the server can't handle packets sent to a node
reply.setError(PacketError.Condition.service_unavailable);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment