Asterisk-Java Call

hmenchaca
Joined: Tue 31 of Aug, 2010

Asterisk-Java Call

Posted:Tue 31 of Aug, 2010 (23:05 UTC)
I want to make a simple call using Asterisk to a Ip telephone but the problem is that , the only thing that the asterisk-console mark is the logged on and the logged off but don't send the Action someone can explain me why?

this is my code

import org.asteriskjava.manager.ManagerConnectionFactory;
import org.asteriskjava.manager.*;
import org.asteriskjava.manager.action.OriginateAction;
import org.asteriskjava.manager.action.*;
import org.asteriskjava.manager.response.ManagerResponse;
import org.asteriskjava.manager.DefaultManagerConnection;
import org.asteriskjava.manager.AuthenticationFailedException;
import org.asteriskjava.manager.ManagerConnection;
import org.asteriskjava.manager.TimeoutException;

import java.io.IOException;



public class RealizarLlamada
{
private ManagerConnection managerConnection;

public RealizarLlamada() throws IOException
{
ManagerConnectionFactory factory = new ManagerConnectionFactory("server","manager", "secret");
managerConnection = factory.createManagerConnection();
}

public void run() throws IOException, AuthenticationFailedException, TimeoutException
{
OriginateAction realizarLlamada;
ManagerResponse respuesta;

realizarLlamada = new OriginateAction();
realizarLlamada.setChannel("SIP/101");
realizarLlamada.setContext("default");
realizarLlamada.setExten("103");
realizarLlamada.setPriority(new Integer(1));
realizarLlamada.setTimeout(new Integer(30000));

// connect to Asterisk and log in
managerConnection.login();

// send the originate action and wait for a maximum of 30 seconds for Asterisk
// to send a reply
respuesta = managerConnection.sendAction(realizarLlamada, 30000);

// print out whether the originate succeeded or not
System.out.println(respuesta.getResponse());

// and finally log off and disconnect
managerConnection.logoff();
}

public static void main(String[] args) throws Exception
{
RealizarLlamada realizarLlamada;

realizarLlamada = new RealizarLlamada();
realizarLlamada.run();
}
}