java - JADE Leap Android App 无法接收主题消息

标签 java android agents-jade

该问题涉及使用两个 Android 手机,并使用主题消息在它们之间发送消息。如果他们都使用发送并且拥有彼此的 AID,他们就可以很好地接收彼此的消息。但是当使用Topic Message的发送功能时,就失效了。

但是,我有一个桌面应用程序,可以毫无问题地接收来自 android 平台的消息。但android平台无法接收他们发来的消息。

我需要对 Android 执行任何特殊步骤才能接收主题消息吗?

创建配置文件以连接到 JADE 时,主题管理服务设置如下

profile.setProperty(Profile.SERVICES, "jade.core.messaging.TopicManagementFEService");

关于解决此问题有什么建议吗?我使用嗅探器查看了这一点,并且两部 Android 手机之间没有发送消息。但它肯定会发送到 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 远程代理管理 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);
}

最佳答案

经过一番折腾和挫折后,我修改了来自 JADE 下载的标题为主题的示例代码,以适用于 Android。这仍然没有成功。我将其发布到 JADE 电子邮件列表并收到以下回复。请注意,以供将来引用,这是版本 4.3.0

Hi,

Actually there was a bug in the way topic registrations from agents in split containers were managed.

Thanks very much for the indication.

The problem should be solved now. In order to get the fix You should get the last JADE sources (server side only: jadeAndroid is not affected at all by this fix) from the JADE SVN repository and recompile the whole.

Let us know if you still have problems.

Bye, Giovanni

关于java - JADE Leap Android App 无法接收主题消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16754026/

相关文章:

Java如何启动CMD并与其保持连接以进行用户交互?

android - 当应用程序显示在后台应用程序列表中时设置操作栏和文本的颜色

android - 如何解决 "Failed to find provider info for com.my.package.urbanairship.provider"?

java - IOUtils.toByteArray() 内存溢出错误

java - JADE 操作() 不起作用

java - (java)如果枚举是静态的 - 如何在我的代码中创建另一个实例(使用 DB40)?

java - Facebook OAuth 异常 : redirect_uri missing

java - JADE - 代理类的实例

java - 服务器响应(JSON 格式)到数组转换

java - 如何在 JADE 中将代理从不同平台注册到位于远程的不同平台?