问题涉及使用两个 android 手机,它们使用主题消息在它们之间发送消息。如果他们都使用 send 并拥有彼此的 AID,他们可以很好地接收彼此的消息。但是,当使用主题消息功能的发送时,它无法工作。
但是,我有一个桌面应用程序,可以毫无问题地接收来自 android 平台的消息。但是android平台无法接收到他们的消息。
我需要对 Android 执行什么特殊步骤来接收主题消息吗?
创建配置文件以连接到 JADE 时,主题管理服务设置如下
profile.setProperty(Profile.SERVICES, "jade.core.messaging.TopicManagementFEService");
关于解决此问题的任何建议?我用嗅探器查看了这个,两个安卓手机之间没有发送消息。但它肯定会发送到 PC 应用程序。
查看管理 GUI 的控制台,我看到消息发出,因为我得到以下信息
May 25, 2013 2:21:25 PM jade.core.BackEndContainer messageOut
INFO: BE-192.168.1.114_55555-1@192.168.1.114 - Delivering OUT message INFORM, size=431
JADE Remote Agent Management GUI 正在桌面上运行,带有以下参数
java -cp .;%JADE_JARS% jade.Boot -gui -host %JADE_IP% -port %JADE_PORT% -nomtp -jade_domain_df_autocleanup true -services jade.core.messaging.TopicManagementService;jade.core.event.NotificationService;jade.core.mobility.AgentMobilityService;jade.core.event.NotificationService;jade.imtp.leap.nio.BEManagementService;
代理使用以下代码订阅主题
public void subscribeTopic(String... topics)
{
for (String topic : topics)
{
TopicManagementHelper helper = (TopicManagementHelper) getHelper(TopicManagementHelper.SERVICE_NAME);
if (helper != null)
{
AID topicID = helper.createTopic(topic.toLowerCase());
try
{
helper.register(topicID);
this.subscribedTopics.add(topic.toLowerCase());
}
catch (ServiceException e)
{
logger.log(Level.SEVERE, "Could not subscribe to topic '" + topic + "'.", e);
}
}
}
}
这是使用 TickerBehaviour 接收消息的行为
public void onTick()
{
boolean done = false;
String topic="location";
LocationData navupdate = readTopicMessageContent(topic, ACLMessage.INFORM, LocationData.class);
if (navupdate != null )
{
while (!done){
navupdate = myLocalAgent.readTopicMessageContent(topic, ACLMessage.INFORM, LocationData.class);
if (navupdate == null)
done = true;
}
}
block();
}
发送主题消息的代码是
public void sendTopicMessageContent(String topicName, int performative, Serializable object)
{
ACLMessage message = new ACLMessage(performative);
message.setOntology(object.getClass().getName());
message.setContentObject(object);
TopicManagementHelper helper = getTopicManager();
AID rcvr=helper.createTopic(topic.toLowerCase());
message.addReceiver(rcvr);
send(message);
}