本文整理汇总了Java中jade.lang.acl.ACLMessage.setConversationId方法的典型用法代码示例。如果您正苦于以下问题:Java ACLMessage.setConversationId方法的具体用法?Java ACLMessage.setConversationId怎么用?Java ACLMessage.setConversationId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jade.lang.acl.ACLMessage
的用法示例。
在下文中一共展示了ACLMessage.setConversationId方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: receiveMessage
import jade.lang.acl.ACLMessage; //导入方法依赖的package包/类
@Override
public void receiveMessage(final FrameworkMessage msg, final String messageID,
final String inReplyToMessageID, final JadeControllerMock jade_ControllerMock) {
final ACLMessage aclMsg = new ACLMessage(ACLMessage.INFORM);
aclMsg.addReceiver(aid);
aclMsg.setContent(msg.toPrettyPrintedXMLString());
aclMsg.setConversationId("jade-controller");
aclMsg.setReplyWith(UUID.randomUUID().toString());
System.out
.println("[JADE Controller Agent ] Sending message to distributed JADE Agent: "
+ distributedSystemID
+ " "
+ distributedAutonomousAgentID
+ " "
+ distAutAgentModelID);
jadeControllerAgent.send(aclMsg);
}
示例2: action
import jade.lang.acl.ACLMessage; //导入方法依赖的package包/类
@Override
public void action() {
ACLMessage message = new ACLMessage(ACLMessage.INFORM);
message.setConversationId("BACKGROUND");
message.addReceiver(myAgent.getSoundAgentName());
my_data.setAction(type);
my_data.setPath(path);
ObjectMapper mapper = new ObjectMapper();
StringWriter sw = new StringWriter();
try {
mapper.writeValue(sw, my_data);
message.setContent(sw.toString());
} catch (Exception e) {
e.printStackTrace();
}
myAgent.send(message);
System.out.println("bg message sent");
}
示例3: action
import jade.lang.acl.ACLMessage; //导入方法依赖的package包/类
@Override
public void action() {
ObjectMapper mapper = new ObjectMapper();
StringWriter sw = new StringWriter();
ACLMessage message = new ACLMessage(ACLMessage.INFORM);
try {
mapper.writeValue(sw, inform);
message.addReceiver(aid);
//message.setConversationId(id.toString());
message.setConversationId("NOTE");
message.setContent(sw.toString());
myAgent.send(message);
} catch (Exception e) {
e.printStackTrace();
}
}
示例4: action
import jade.lang.acl.ACLMessage; //导入方法依赖的package包/类
@Override
public void action() {
ACLMessage reply=msg.createReply();
reply.setPerformative(ACLMessage.INFORM);
reply.setConversationId(Constance.GROUP_CREATED);
try {
reply.setContentObject(myAgent.getDict());
System.out.println("set defautlistmodele of reply\n");
myAgent.send(reply);
System.out.println("multiAgent sent reply\n");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
示例5: action
import jade.lang.acl.ACLMessage; //导入方法依赖的package包/类
@Override
public void action() {
try {
final Date proposalDeadline = caller.getProposalDeadline(conversationId);
final Collection<DFAgentDescription> stationAgents = getCfpRecipients();
final ACLMessage cfp = new ACLMessage(ACLMessage.CFP);
cfp.setConversationId(conversationId);
cfp.setReplyWith(messageId);
cfp.setReplyByDate(proposalDeadline);
for (final DFAgentDescription agent : stationAgents) {
cfp.addReceiver(agent.getName());
}
caller.configureCfp(conversationId, cfp);
myAgent.send(cfp);
myAgent.addBehaviour(new CollectProposalsBehaviour(proposalDeadline));
} catch (FIPAException e) {
LOG.error("Unable to contact stations.", e);
}
}
示例6: sendMsg
import jade.lang.acl.ACLMessage; //导入方法依赖的package包/类
public void sendMsg(Message m) throws Exception {
ACLMessage acl = jasonToACL(m);
acl.addReceiver(new AID(m.getReceiver(), AID.ISLOCALNAME));
if (m.getInReplyTo() != null) {
String convid = conversationIds.get(m.getInReplyTo());
if (convid != null) {
acl.setConversationId(convid);
}
}
if (logger.isLoggable(Level.FINE)) logger.fine("Sending message: " + acl);
send(acl);
}
示例7: action
import jade.lang.acl.ACLMessage; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public void action() {
if(first){
ACLMessage multiPlayRegister = new ACLMessage(ACLMessage.SUBSCRIBE);
multiPlayRegister.setConversationId("register");
multiPlayRegister.setSender(myAgent.getAID());
multiPlayRegister.addReceiver(myAgent.getServerName());
multiPlayRegister.setContent("getting in");
myAgent.send(multiPlayRegister);
first = false;
}
if(!myAgent.isMultiple_mode()){
ACLMessage multiPlayUnregister = new ACLMessage(ACLMessage.SUBSCRIBE);
multiPlayUnregister.setConversationId("unregister");
multiPlayUnregister.setSender(myAgent.getAID());
multiPlayUnregister.addReceiver(myAgent.getServerName());
multiPlayUnregister.setContent("getting out");
myAgent.send(multiPlayUnregister);
done=true;
}
MessageTemplate mt =
MessageTemplate.and(MessageTemplate.MatchConversationId("updateDICT"),
MessageTemplate.MatchPerformative(ACLMessage.INFORM));
ACLMessage update_message = myAgent.receive(mt);
if(update_message!=null){
System.out.println("receive update dict");
if(update_message.getPerformative()==ACLMessage.INFORM){
try {
myAgent.setDict((DefaultListModel<String>)update_message.getContentObject());
} catch (UnreadableException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
示例8: info_all_player
import jade.lang.acl.ACLMessage; //导入方法依赖的package包/类
private void info_all_player() {
ACLMessage info_player_change = new ACLMessage(ACLMessage.INFORM);
for (int i = 0; i < list_member.size(); i++) {
info_player_change.addReceiver(list_member.get(i));
}
info_player_change.setSender(myAgent.getAID());
try {
info_player_change.setContentObject(dict_player);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
info_player_change.setConversationId(Constance.MEMBER_CHANGE);
myAgent.send(info_player_change);
}
示例9: info_all_player_start_game
import jade.lang.acl.ACLMessage; //导入方法依赖的package包/类
private void info_all_player_start_game(ACLMessage m) {
ACLMessage info_game_start = new ACLMessage(ACLMessage.CONFIRM);
for (int i = 0; i < list_member.size(); i++) {
info_game_start.addReceiver(list_member.get(i));
}
info_game_start.setConversationId(m.getConversationId());
info_game_start.setSender(myAgent.getAID());
MyAID sound_agent = new MyAID(host_sound_name.getName(), host_sound_name.getAddressesArray()[0]);
info_game_start.setReplyWith(sound_agent.toJSON());
info_game_start.setContent(Constance.CONFIRM_START);
myAgent.send(info_game_start);
}
示例10: info_all_player_change_sound_name
import jade.lang.acl.ACLMessage; //导入方法依赖的package包/类
private void info_all_player_change_sound_name(ACLMessage m) {
ACLMessage info_sound_change = new ACLMessage(ACLMessage.CONFIRM);
for (int i = 0; i < list_member.size(); i++) {
info_sound_change.addReceiver(list_member.get(i));
}
info_sound_change.setConversationId(m.getConversationId());
info_sound_change.setSender(myAgent.getAID());
MyAID sound_agent = new MyAID(host_sound_name.getName(), host_sound_name.getAddressesArray()[0]);
info_sound_change.setReplyWith(sound_agent.toJSON());
info_sound_change.setContent(Constance.Sound_Change);
myAgent.send(info_sound_change);
}
示例11: rejectProposals
import jade.lang.acl.ACLMessage; //导入方法依赖的package包/类
private void rejectProposals(Collection<ACLMessage> proposals) {
for (final ACLMessage proposal : proposals) {
final ACLMessage response = proposal.createReply();
response.setConversationId(conversationId);
response.setPerformative(ACLMessage.REJECT_PROPOSAL);
myAgent.send(response);
}
}
示例12: action
import jade.lang.acl.ACLMessage; //导入方法依赖的package包/类
public void action() {
switch (step) {
case 0:
// Send the cfp to all sellers
ACLMessage cfp = new ACLMessage(ACLMessage.CFP);
for (int i = 0; i < sellerAgents.length; ++i) {
cfp.addReceiver(sellerAgents[i]);
}
cfp.setContent(targetBookTitle);
cfp.setConversationId("book-trade");
cfp.setReplyWith("cfp"+System.currentTimeMillis()); // Unique value
myAgent.send(cfp);
// Prepare the template to get proposals
mt = MessageTemplate.and(MessageTemplate.MatchConversationId("book-trade"),
MessageTemplate.MatchInReplyTo(cfp.getReplyWith()));
step = 1;
break;
case 1:
// Receive all proposals/refusals from seller agents
ACLMessage reply = myAgent.receive(mt);
if (reply != null) {
// Reply received
if (reply.getPerformative() == ACLMessage.PROPOSE) {
// This is an offer
int price = Integer.parseInt(reply.getContent());
if (bestSeller == null || price < bestPrice) {
// This is the best offer at present
bestPrice = price;
bestSeller = reply.getSender();
}
}
repliesCnt++;
if (repliesCnt >= sellerAgents.length) {
// We received all replies
step = 2;
}
} else {
block();
}
break;
case 2:
// Send the purchase order to the seller that provided the best offer
ACLMessage order = new ACLMessage(ACLMessage.ACCEPT_PROPOSAL);
order.addReceiver(bestSeller);
order.setContent(targetBookTitle);
order.setConversationId("book-trade");
order.setReplyWith("order"+System.currentTimeMillis());
myAgent.send(order);
// Prepare the template to get the purchase order reply
mt = MessageTemplate.and(MessageTemplate.MatchConversationId("book-trade"),
MessageTemplate.MatchInReplyTo(order.getReplyWith()));
step = 3;
break;
case 3:
// Receive the purchase order reply
reply = myAgent.receive(mt);
if (reply != null) {
// Purchase order reply received
if (reply.getPerformative() == ACLMessage.INFORM) {
// Purchase successful. We can terminate
System.out.println(targetBookTitle+" successfully purchased from agent "+reply.getSender().getName());
System.out.println("Price = "+bestPrice);
myAgent.doDelete();
} else {
System.out.println("Attempt failed: requested book already sold.");
}
step = 4;
} else {
block();
}
break;
}
}
示例13: action
import jade.lang.acl.ACLMessage; //导入方法依赖的package包/类
@Override
public void action() {
MessageTemplate mt = MessageTemplate.and(MessageTemplate.or(MessageTemplate.or(
MessageTemplate.MatchPerformative(ACLMessage.REQUEST),
MessageTemplate.MatchPerformative(ACLMessage.SUBSCRIBE)),
MessageTemplate.MatchPerformative(ACLMessage.CANCEL)
),
MessageTemplate.MatchConversationId("Room" + room_id));
ACLMessage message = myAgent.receive(mt);
if (message != null) {
if (message.getPerformative() == ACLMessage.SUBSCRIBE) {
System.out.println("asking for entering a existed room");
if (message.getContent().equals(Constance.EnterGroupMode)){
setPlayerDict(message.getSender().getName());
list_member.add(message.getSender());
list_member_map.put(message.getSender(),MyAID.toAID(message.getReplyWith()));
answer_guest_ack(message);
player_changed = true;
}
} else if (message.getPerformative() == ACLMessage.CANCEL) {
System.out.println("asking for quiting a existed room");
if (message.getContent().equals(Constance.ExitGroupMode)){
removePlayerDict(message.getSender().getName());
list_member.remove(message.getSender());
list_member_map.remove(message.getSender());
player_changed = true;
if (list_member.size() == 0) {
game_over = true;
System.out.println("game over, game manager done");
myAgent.getDict().removeElement(conversation_id);
info_multiplay_users();
} else if(message.getSender().equals(host_name)){
info_multiplay_users();
//change host to the next one
host_name = list_member.get(0);
host_sound_name = list_member_map.get(host_name);
info_all_player_change_sound_name(message);
ACLMessage inform_host = new ACLMessage(ACLMessage.INFORM);
inform_host.addReceiver(host_name);
inform_host.setConversationId("StartVisibility");
inform_host.setContent("true");
myAgent.send(inform_host);
}
answer_exit_req(message);
}
} else if(message.getPerformative()==ACLMessage.REQUEST){
if(message.getContent().equals(Constance.START_GAME) && message.getSender().equals(host_name)){
info_all_player_start_game(message);
myAgent.getDict().removeElement(conversation_id);
info_multiplay_users();
}
}
}
if(initialize){
//creat a groupe of game
// int countGroup=myAgent.getDict().size();
// countGroup+=1;
//update room list
conversation_id = "Room"+room_id;
myAgent.setDict(conversation_id);
info_multiplay_users();
setPlayerDict(host_msg.getSender().getName());
//info_all_player();
list_member.add(host_msg.getSender());
list_member_map.put(host_msg.getSender(),MyAID.toAID(host_msg.getReplyWith()));
host_name = host_msg.getSender();
System.out.println(host_msg.getReplyWith());
host_sound_name = MyAID.toAID(host_msg.getReplyWith());
answer_host_ack();
player_changed = true;
initialize = false;
}
if (player_changed) {
info_all_player();
player_changed = false;
}
}