--- projects/cms/source/server/uk/org/iscream/cms/server/clientinterface/PacketSorter.java 2001/02/26 23:41:35 1.7 +++ projects/cms/source/server/uk/org/iscream/cms/server/clientinterface/PacketSorter.java 2001/02/28 10:26:47 1.8 @@ -16,7 +16,7 @@ import java.util.*; * hosts it would like to listen for. * * @author $Author: tdb $ - * @version $Id: PacketSorter.java,v 1.7 2001/02/26 23:41:35 tdb Exp $ + * @version $Id: PacketSorter.java,v 1.8 2001/02/28 10:26:47 tdb Exp $ */ class PacketSorter extends Thread { @@ -25,7 +25,7 @@ class PacketSorter extends Thread { /** * The current CVS revision of this class */ - public final String REVISION = "$Revision: 1.7 $"; + public final String REVISION = "$Revision: 1.8 $"; //---STATIC METHODS--- @@ -67,23 +67,35 @@ class PacketSorter extends Thread { // find out which host this packet is actually for XMLPacketMaker xmlPacketMaker = new XMLPacketMaker(xml); XMLPacket packet = xmlPacketMaker.createXMLPacket(); - String host = packet.getParam("packet.attributes.machine_name"); - // look in the hostMap to see if anyone wants this data - if(_hostMap.containsKey(host)) { - LinkedList list = (LinkedList) _hostMap.get(host); - Iterator i = list.iterator(); - // push the data to the listening Handler's queue + String packetType = packet.getParam("packet.attributes.type"); + // check if we need to send it regardless + if(packetType.equals("data") || packetType.equals("heartbeat")) { + String host = packet.getParam("packet.attributes.machine_name"); + + // look in the hostMap to see if anyone wants this data + if(_hostMap.containsKey(host)) { + LinkedList list = (LinkedList) _hostMap.get(host); + Iterator i = list.iterator(); + // push the data to the listening Handler's queue + while(i.hasNext()) { + ((Queue) i.next()).add(xml); + } + } + + // any handler in this list wants all packets, so send + // it on to them regardless + Iterator i = _allHostsList.iterator(); while(i.hasNext()) { ((Queue) i.next()).add(xml); - } + } } - - // any handler in this list wants all packets, so send - // it on to them regardless - Iterator j = _allHostsList.iterator(); - while(j.hasNext()) { - ((Queue) j.next()).add(xml); + else { + // send to all hosts because it's a special packet + Iterator i = _allHostsList.iterator(); + while(i.hasNext()) { + ((Queue) i.next()).add(xml); + } } } }