在玉器远程平台之间传递ACL消息 [英] Passing ACL messages between jade remote platforms

查看:84
本文介绍了在玉器远程平台之间传递ACL消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在2个翡翠平台之间传递ACL消息。我实现了代码以在同一容器中的代理之间传递消息。很好但是我无法开发该代码在远程平台之间传递消息。

I need to pass an ACL message between 2 jade platforms. I implemented my code to pass messages between agents in the same container. That works fine. But I could not develop that code to pass messages between remote platforms.

以下是我为同一容器中的代理实现的内容。在发送方代理代码中,result []仅使代理位于同一平台上。

Below is what I implemented for the agents in the same container. In the sender agent code the result[] only gets the agents in the same platform.

我缺少什么?
是否有任何方法可以获取远程平台中的代理列表?

What am I missing? Is there any method to get the list of agents in the remote platform?

发件人代理

DFAgentDescription temp = new DFAgentDescription();
    try
    {
        //DFAgentDescription[] result = DFService.search(this,temp);
        SearchConstraints sc = new SearchConstraints();
        DFAgentDescription[] result=DFService.search(this,temp,sc);
        ACLMessage acl = new ACLMessage(ACLMessage.REQUEST);

        System.out.println("Agents: ");
        for(int i=0;i<result.length;i++)
        {
            if(result[i].getName().getLocalName().equalsIgnoreCase("R1"))
            {
                acl.addReceiver(result[i].getName());
                System.out.print(" , "+result[i].getName().getLocalName());
            }
        }

        acl.setContent("Hello...");
        this.send(acl);
        System.out.println("Message Sent...");
    }
    catch(FIPAException e)
    {
        System.out.println("Error !: "+e);
    }

收件人代理

addBehaviour(new CyclicBehaviour()
    {
        public void action()
        {
            ACLMessage  msg = myAgent.receive();
            if(msg != null)
            {
                if(msg.getPerformative()== ACLMessage.REQUEST)
                {
                    String content = msg.getContent();
                    if ((content != null))
                    {
                        System.out.println("Received Request from "+msg.getSender().getLocalName());
                        System.out.println("Received Message : "+content);
                    }
                    else
                    {   
                        block();
                    }
                }
            }
            else
            {
                block();
            }
        }
    });


推荐答案

尝试一下

AID r=new AID("agent-name@platform",AID.ISGUID);
r.addAddresses("http://192.168.1.1:7778/acc");
acl.addReceiver(r);
acl.setContent("Hello.!");
this.send(acl);
System.out.println("\nMessage Sent to "+r);

我的本​​地IP使用您自己的IP或主机名。

Instead my local IP use your own IP or hostname.

这篇关于在玉器远程平台之间传递ACL消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆