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


Java ACLMessage.setSender方法代码示例

本文整理汇总了Java中jade.lang.acl.ACLMessage.setSender方法的典型用法代码示例。如果您正苦于以下问题:Java ACLMessage.setSender方法的具体用法?Java ACLMessage.setSender怎么用?Java ACLMessage.setSender使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在jade.lang.acl.ACLMessage的用法示例。


在下文中一共展示了ACLMessage.setSender方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: action

import jade.lang.acl.ACLMessage; //导入方法依赖的package包/类
public void action() {
     ResultsAgent a = (ResultsAgent)myAgent;
     
      // Send result before closing down
     ACLMessage msg = new ACLMessage(ACLMessage.INFORM);
     msg.setSender(a.getAID());
     msg.addReceiver(new AID(SendTo, false));
     try {
         Object[] oMsg=new Object[3];
         oMsg[0] = ID;
         oMsg[1] = bText1;
         oMsg[2] = bText2;
         
         msg.setContentObject(oMsg);
     } catch (IOException ex) {
         System.err.println("Cannot add result to message. Sending empty message.");
         ex.printStackTrace(System.err);
     }
     
     a.send(msg);        
}
 
开发者ID:ayushoriginal,项目名称:Ngram-Graphs,代码行数:22,代码来源:ResultsAgent.java

示例2: action

import jade.lang.acl.ACLMessage; //导入方法依赖的package包/类
/** Actually sends the result to the dispatching agent.
  */
 public void action() {
     synchronized (myAgent) {
         NGramDocumentComparatorAgent a = (NGramDocumentComparatorAgent)myAgent;
     
          // Send result before closing down
         ACLMessage msg = new ACLMessage(ACLMessage.INFORM);
         msg.setSender(a.getAID());
         msg.addReceiver(a.ResultConsumer);
         try {
             msg.setContentObject(Result);
         } catch (IOException ex) {
             System.err.println("Cannot add result to message. Sending empty message.");
             ex.printStackTrace(System.err);
         }

         a.send(msg);
     }
     
}
 
开发者ID:ayushoriginal,项目名称:Ngram-Graphs,代码行数:22,代码来源:NGramDocumentComparatorAgent.java

示例3: sendMsgAvailableMachinesRequest

import jade.lang.acl.ACLMessage; //导入方法依赖的package包/类
/**
 * Forwards a request for available machines to the server.cliebnt.
 */
private void sendMsgAvailableMachinesRequest() {
	
	// --- Get the local Address of JADE ------------------------
	String myPlatformAddress = myContainer.getPlatformID();
	
	// --- Define the AgentAction -------------------------------
	ClientAvailableMachinesRequest request = new ClientAvailableMachinesRequest();
	
	Action act = new Action();
	act.setActor(myContainer.getAMS());
	act.setAction(request);

	// --- Define receiver of the Message ----------------------- 
	AID agentGUIAgent = new AID("server.client" + "@" + myPlatformAddress, AID.ISGUID );
	//mainPlatformAgent.addAddresses(mainPlatform.getHttp4mtp());
	
	// --- Build Message ----------------------------------------
	ACLMessage msg = new ACLMessage(ACLMessage.INFORM);
	msg.setSender(myContainer.getAMS());
	msg.addReceiver(agentGUIAgent);		
	msg.setLanguage(new SLCodec().getName());
	msg.setOntology(AgentGUI_DistributionOntology.getInstance().getName());
	try {
		msg.setContentObject(act);
	} catch (IOException errCont) {
		errCont.printStackTrace();
	}

	// --- Send message -----------------------------------------
	myContainer.postMessageToLocalAgent(msg, agentGUIAgent);
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:35,代码来源:LoadService.java

示例4: sendMsgRemoteContainerRequest

import jade.lang.acl.ACLMessage; //导入方法依赖的package包/类
/**
 * This method configures and send a ACLMessage to start a new remote-Container.
 *
 * @param remConf the RemoteContainerConfig
 * @param preventUsageOfAlreadyUsedComputers the boolean prevent usage of already used computers
 * @return the name of the container
 */
private String sendMsgRemoteContainerRequest(RemoteContainerConfig remConf) {
	
	// --- If the remote-configuration is null configure it now -
	if (remConf==null) {
		remConf = this.getRemoteContainerConfigAuto();
	}
	
	// --- Define the AgentAction -------------------------------
	ClientRemoteContainerRequest req = new ClientRemoteContainerRequest();
	req.setRemoteConfig(remConf);
	
	Action act = new Action();
	act.setActor(myContainer.getAMS());
	act.setAction(req);

	// --- Define receiver of the Message ----------------------- 
	AID agentGUIAgent = new AID(Platform.BackgroundSystemAgentApplication +  "@" + this.myContainer.getPlatformID(), AID.ISGUID);
	
	// --- Build Message ----------------------------------------
	ACLMessage msg = new ACLMessage(ACLMessage.INFORM);
	msg.setSender(myContainer.getAMS());
	msg.addReceiver(agentGUIAgent);		
	msg.setLanguage(new SLCodec().getName());
	msg.setOntology(AgentGUI_DistributionOntology.getInstance().getName());
	try {
		msg.setContentObject(act);
	} catch (IOException errCont) {
		errCont.printStackTrace();
	}

	// --- Send message -----------------------------------------
	myContainer.postMessageToLocalAgent(msg, agentGUIAgent);
	
	// --- Remind, that we're waiting for this container --------
	loadInfo.setNewContainer2Wait4(remConf.getJadeContainerName());
	
	// --- Return -----------------------------------------------
	return remConf.getJadeContainerName();
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:47,代码来源:LoadService.java

示例5: complete

import jade.lang.acl.ACLMessage; //导入方法依赖的package包/类
/** Completes the evaluation process, updating the dispatched agents of the 
 *event .
 */
public void complete() {
    System.err.println("Completed successfully. Releasing sent agents...");
    
    String sCur;
    Object oNext;
    // For every agent
    while ((oNext=ActiveAgents.poll()) != null) {
        sCur = (String)oNext;
        // Send termination signal
        ACLMessage msg = new ACLMessage(ACLMessage.CANCEL);
        msg.setSender(getAID());
        msg.addReceiver(new AID(sCur, false));
        msg.setContent(NGramDocumentComparatorAgent.TERMINATION_MESSAGE);

        send(msg);        
    }
    psOutputStream.flush();
    psOutputStream.close();
    
    addBehaviour(new WakerBehaviour(this, 10000) {
        public void onWake() {
            doDelete();
        }
    });
    
}
 
开发者ID:ayushoriginal,项目名称:Ngram-Graphs,代码行数:30,代码来源:ResultsAgent.java

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

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

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

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


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