当前位置: 首页>>代码示例>>Java>>正文


Java ACLMessage.SUBSCRIBE属性代码示例

本文整理汇总了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");
}
 
开发者ID:hukewei,项目名称:leapband,代码行数:7,代码来源:EnterGroupBehaviour.java

示例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();
			}
		}
	}
}
 
开发者ID:hukewei,项目名称:leapband,代码行数:40,代码来源:MultiPlayUpdateBehaviour.java

示例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");
}
 
开发者ID:hukewei,项目名称:leapband,代码行数:6,代码来源:CreatGroupBehaviour.java

示例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;
		}	
	}
 
开发者ID:hukewei,项目名称:leapband,代码行数:77,代码来源:GameManageBehaviour.java


注:本文中的jade.lang.acl.ACLMessage.SUBSCRIBE属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。