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);
}
});
}