/**
 * EnviaMsg.java
 *
 * @author Wanderson C. Bragança <wanderson.wbc@gmail.com>
 * @link http://www.wanderson.wordpress.com
 * @copyright Copyright © 2009
 * @version  14/04/2009
 */

import jade.proto.*;
import jade.lang.acl.*;
import jade.domain.mobility.MobilityOntology;
import jade.domain.FIPANames;
import jade.content.onto.basic.Action;
import javax.swing.JOptionPane;


public class EnviaMsg extends SimpleAchieveREInitiator {
    
    private ACLMessage request;
    
    public EnviaMsg(SGRBA a,Action action) {
        // chama o construtor de FipaRequestInitiatorBehaviour
        super(a, new ACLMessage(ACLMessage.REQUEST));
        request = (ACLMessage)getDataStore().get(REQUEST_KEY);
        // enche todos os par�metros do pedido ACLMessage
           
        request.setLanguage(FIPANames.ContentLanguage.FIPA_SL0);
        request.setOntology(MobilityOntology.NAME);
        request.setProtocol(FIPANames.InteractionProtocol.FIPA_REQUEST);
        // cria o indice do ACLMessage
                
        try {
            a.getContentManager().fillContent(request, action);
            request.addReceiver(action.getActor());
            a.send(request);
        } catch (Exception ex) { JOptionPane.showMessageDialog(null,"erro");ex.printStackTrace(); }

        reset(request);
    }   
}

