Commit d922708f authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gaston

Packets directed to a component's address are now passed to the component. JM-250


git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@1219 b35dd754-fafc-0310-a699-88a17e54d16e
parent 59162ac0
......@@ -11,10 +11,12 @@
package org.jivesoftware.messenger.spi;
import org.jivesoftware.messenger.container.BasicModule;
import org.jivesoftware.messenger.*;
import org.jivesoftware.messenger.auth.UnauthorizedException;
import org.jivesoftware.messenger.container.BasicModule;
import org.jivesoftware.messenger.net.SocketPacketWriteHandler;
import org.xmpp.component.Component;
import org.xmpp.packet.JID;
import org.xmpp.packet.Packet;
/**
......@@ -32,8 +34,11 @@ public class PacketDelivererImpl extends BasicModule implements PacketDeliverer
private OfflineMessageStrategy messageStrategy;
private SessionManager sessionManager;
private InternalComponentManager componentManager;
public PacketDelivererImpl() {
super("Packet Delivery");
componentManager = InternalComponentManager.getInstance();
}
public void deliver(Packet packet) throws UnauthorizedException, PacketException {
......@@ -43,6 +48,19 @@ public class PacketDelivererImpl extends BasicModule implements PacketDeliverer
if (deliverHandler == null) {
throw new PacketException("Could not send packet - no route" + packet.toString());
}
// Check if the target of the packet is the a component itself. If it does then just pass
// the packet to the component for processing it
JID recipient = packet.getTo();
if (recipient != null && recipient.getNode() == null && recipient.getResource() == null) {
// Check for registered components
Component component = componentManager.getComponent(recipient);
if (component != null) {
component.processPacket(packet);
return;
}
}
// Let the SocketPacketWriteHandler process the packet. SocketPacketWriteHandler may send
// it over the socket or store it when user is offline or drop it.
deliverHandler.process(packet);
}
......
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