gpt4 book ai didi

java - 如何从普通(非代理)java 类执行 JADE 代理?

转载 作者:行者123 更新时间:2023-11-30 10:39:07 33 4
gpt4 key购买 nike

我想从其他不是代理的类向代理发送消息。例如 Servlet 或主要静态类。

最佳答案

这是一个普通类,不是代理:

        MainContainerAgentsRetriever retriever = new MainContainerAgentsRetriever();
JadeGateway.execute(retriever);
// At this point the retriever behaviour has been fully executed --> the list of
// agents running in the Main Container is available: get it and print it
List agents = retriever.getAgents();

if (agents != null) {
System.out.println("Agents living in the Main Container: ");
for (int i = 0; i < agents.size(); ++i) {
System.out.println("- " + ((AID) agents.get(i)).getLocalName());

ACLMessage msg = new ACLMessage();
msg.addReceiver(((AID) agents.get(i)));
msg.setContent("salam refigha");
retriever.send(msg);



}
}

关于java - 如何从普通(非代理)java 类执行 JADE 代理?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39410873/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com