Commit 5a4cf8d1 authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gato

Cache local user session and send packets through cache session whenever possible. JM-480

git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@3168 b35dd754-fafc-0310-a699-88a17e54d16e
parent 33741004
/**
* $RCSfile$
* $RCSfile: MUCRoleImpl.java,v $
* $Revision$
* $Date$
*
......@@ -15,6 +15,9 @@ import org.dom4j.Element;
import org.dom4j.DocumentHelper;
import org.dom4j.QName;
import org.jivesoftware.messenger.PacketRouter;
import org.jivesoftware.messenger.ClientSession;
import org.jivesoftware.messenger.XMPPServer;
import org.jivesoftware.messenger.Session;
import org.jivesoftware.messenger.muc.MUCRole;
import org.jivesoftware.messenger.muc.MUCRoom;
import org.jivesoftware.messenger.muc.MUCUser;
......@@ -80,6 +83,12 @@ public class MUCRoleImpl implements MUCRole {
*/
private Element extendedInformation;
/**
* Cache session of local user that is a room occupant. If the room occupant is not a local
* user then nothing will be cached and packets will be sent through the PacketRouter.
*/
private ClientSession session;
/**
* Create a new role.
*
......@@ -103,6 +112,9 @@ public class MUCRoleImpl implements MUCRole {
this.router = packetRouter;
this.role = role;
this.affiliation = affiliation;
// Cache the user's session (will only work for local users)
this.session = XMPPServer.getInstance().getSessionManager().getSession(presence.getFrom());
extendedInformation =
DocumentHelper.createElement(QName.get("x", "http://jabber.org/protocol/muc#user"));
calculateExtendedInformation();
......@@ -207,7 +219,14 @@ public class MUCRoleImpl implements MUCRole {
return;
}
packet.setTo(user.getAddress());
router.route(packet);
if (session != null && session.getStatus() == Session.STATUS_AUTHENTICATED) {
// Send the packet directly to the local user session
session.process(packet);
}
else {
router.route(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