Package it.unito.di.artifact.CommunicationArtifact

Examples of it.unito.di.artifact.CommunicationArtifact.CARole


    addBehaviour(new OneShotBehaviour() {
     
      @Override
      public void action() {
        ArtifactId art = Role.createArtifact(ARTIFACT_NAME, CommunicationArtifactImpl.class);
        CARole user = (CARole)(Role.enact(CommunicationArtifact.CA_ROLE, art, this, myAgent.getAID()));
        RoleId receiver = new RoleId(CommunicationArtifact.CA_ROLE, RoleId.GENERIC_ROLE);
        try {
          Thread.sleep(1000);
        } catch (InterruptedException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }
        RoleMessage test = new RoleMessage();
        RoleMessage test1 = new RoleMessage();
        test.setContents("Prova "+user.getRoleId());
        test.setRoleSender(user.getRoleId());
        test.setRoleReceiver(receiver);
        int r = (int) (Math.random()*100);
        if (r < 50)
          test.setPerformative(ACLMessage.INFORM);
        else
          test.setPerformative(ACLMessage.AGREE);
                       
        user.send(test);
               
      }
    });
  }
View Full Code Here


     
      @Override
      public void action() {
       
        ArtifactId art = Role.createArtifact(ARTIFACT_NAME, CommunicationArtifactImpl.class);
        CARole user = (CARole)(Role.enact(CommunicationArtifact.CA_ROLE, art, this, myAgent.getAID()));
       
        try {
          Thread.sleep(1000);
        } catch (InterruptedException e) {
          logger.error("Interrupted exception in receive");
          e.printStackTrace();
        }
        logger.info("Inizio a ricevere");
        ArrayList<RoleMessage> receive = user.receiveAll(ACLMessage.AGREE);
        logger.info("Message received: "+receive.size());
        if (receive.size() != 0) {
          // respond to message
          RoleMessage answer = new RoleMessage(user.getRoleId(),receive.get(0).getRoleSender(),"Ti rispondo alla prova!");
          user.send(answer);
        }
       
       
       
      }
View Full Code Here

    addBehaviour(new OneShotBehaviour() {
     
      @Override
      public void action() {
        ArtifactId art = Role.createArtifact(ARTIFACT_NAME, CommunicationArtifactImpl.class);
        CARole user = (CARole)(Role.enact(CommunicationArtifact.CA_ROLE, art, this, myAgent.getAID()));
        RoleId receiver = new RoleId(CommunicationArtifact.CA_ROLE, RoleId.GENERIC_ROLE);
        try {
          Thread.sleep(1000);
        } catch (InterruptedException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }
        CAMessage test = new CAMessage();
        CAMessage test1 = new CAMessage();
        test.setContents("Prova "+user.getRoleId());
        test.setRoleSender(user.getRoleId());
        test.setRoleReceiver(receiver);
        int r = (int) (Math.random()*100);
        if (r < 50)
          test.setPerformative(ACLMessage.INFORM);
        else
          test.setPerformative(ACLMessage.AGREE);
                       
        user.send(test);
               
      }
    });
  }
View Full Code Here

     
      @Override
      public void action() {
       
        ArtifactId art = Role.createArtifact(ARTIFACT_NAME, CommunicationArtifactImpl.class);
        CARole user = (CARole)(Role.enact(CommunicationArtifact.CA_ROLE, art, this, myAgent.getAID()));
       
        try {
          Thread.sleep(1000);
        } catch (InterruptedException e) {
          logger.error("Interrupted exception in receive");
          e.printStackTrace();
        }
        logger.info("Inizio a ricevere");
        ArrayList<CAMessage> receive = user.receiveAll(ACLMessage.AGREE);
        logger.info("Message received: "+receive.size());
        if (receive.size() != 0) {
          // respond to message
          CAMessage answer = new CAMessage(user.getRoleId(),receive.get(0).getRoleSender(),"Ti rispondo alla prova!");
          user.send(answer);
        }
       
       
       
      }
View Full Code Here

TOP

Related Classes of it.unito.di.artifact.CommunicationArtifact.CARole

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.