Пример #1
0
 private void sendAll(Message m) {
   m.setSender(getAddress());
   for (Iterator i = distantKernels.iterator(); i.hasNext(); ) {
     Message m2 = (Message) m.clone();
     AgentAddress distantK = (AgentAddress) i.next();
     m2.setReceiver(distantK);
     sendDistantMessage(m2);
   }
 }
Пример #2
0
 final synchronized void updateDistantOrgs(
     AgentAddress initiator, String community, String groupName) {
   AgentAddress[] receivers = communities.getRolePlayers(community, SITE);
   Organization orgOfTheGroup = (Organization) organizations.get(community);
   for (int i = 0; i < receivers.length; i++) {
     if (!receivers[i].equals(getAddress())) {
       Message m =
           new SynchroMessage(initiator, community, orgOfTheGroup.getGroup(groupName), groupName);
       m.setSender(getAddress());
       m.setReceiver(receivers[i]);
       sendDistantMessage(m);
     }
   }
 }
Пример #3
0
 final synchronized void updateDistantOrgs(
     int code,
     AgentAddress initiator,
     String community,
     String groupName,
     String roleName,
     Object memberCard) {
   AgentAddress[] receivers = communities.getRolePlayers(community, SITE);
   for (int i = 0; i < receivers.length; i++) {
     if (!receivers[i].equals(getAddress())) {
       Message m = new SynchroMessage(code, initiator, community, groupName, roleName, memberCard);
       m.setSender(getAddress());
       m.setReceiver(receivers[i]);
       sendDistantMessage(m);
     }
   }
 }
Пример #4
0
 final synchronized void tryMigration(KernelAddress destination, AgentAddress traveler) {
   AbstractAgent ref = Kernel.getReference(traveler);
   Message message = new SynchroMessage(ref);
   for (Iterator i = distantKernels.iterator(); i.hasNext(); ) {
     AgentAddress potentialReceiver = (AgentAddress) i.next();
     if (potentialReceiver.getKernel().equals(destination)) {
       message.setReceiver(potentialReceiver);
       break;
     }
   }
   if (message.getReceiver() != null && ref != null) {
     // kernelAgent.callshook 	...  updateDistantOrgs(Kernel.MIGRATION,traveler,null,null,null);
     if (ref instanceof Agent) {
       ((Agent) ref).getAgentThread().stop();
       ref.setCurrentKernel(null);
       // ref.messageBox=null;
     }
     getCurrentKernel().removeAgentFromOrganizations(traveler);
     getCurrentKernel().removeReferenceOf(traveler);
     message.setSender(getAddress());
     sendDistantMessage(message);
   }
 }