public final boolean accept(VerticalCommand cmd) {
String name = cmd.getName();
if (name.equals(MessagingSlice.SEND_MESSAGE)) {
AID sender = (AID) cmd.getParam(0);
GenericMessage gMsg = (GenericMessage) cmd.getParam(1);
AID receiver = (AID) cmd.getParam(2);
if (TopicUtility.isTopic(receiver)) {
// This message is directed to a Topic
AID topic = receiver;
if (myLogger.isLoggable(Logger.FINE)) {
myLogger.log(Logger.FINE, "Handling message about topic "+topic.getLocalName());
}
ACLMessage msg = gMsg.getACLMessage();
Collection interestedAgents = topicTable.getInterestedAgents(topic, msg);
if (interestedAgents.size() > 0) {
// Forward the message to all agents interested in that topic.
// Note that if no agents are currently listening to this topic, the message is simply swallowed
msg.addUserDefinedParameter(ACLMessage.IGNORE_FAILURE, "true");
gMsg.setModifiable(false);
Iterator it = interestedAgents.iterator();
while (it.hasNext()) {
AID target = (AID) it.next();
if (myLogger.isLoggable(Logger.FINE)) {
myLogger.log(Logger.FINE, "Forwarding message to agent "+target.getName());