本文整理汇总了Java中jade.lang.acl.ACLMessage.SUBSCRIBE属性的典型用法代码示例。如果您正苦于以下问题:Java ACLMessage.SUBSCRIBE属性的具体用法?Java ACLMessage.SUBSCRIBE怎么用?Java ACLMessage.SUBSCRIBE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类jade.lang.acl.ACLMessage
的用法示例。
在下文中一共展示了ACLMessage.SUBSCRIBE属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: EnterGroupBehaviour
public EnterGroupBehaviour(UserAgent myAgent, String content) {
super();
this.myAgent = myAgent;
this.msg=new ACLMessage(ACLMessage.SUBSCRIBE);
msg_conversation = content;
System.out.println("enter room behaviour created");
}
示例2: action
@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();
}
}
}
}
示例3: CreatGroupBehaviour
public CreatGroupBehaviour(UserAgent myAgent) {
super();
this.myAgent = myAgent;
this.msg=new ACLMessage(ACLMessage.SUBSCRIBE); //content = 104
System.out.println("create room behaviour created");
}
示例4: action
@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;
}
}