Olá.
Estou fazendo uma aliplicação que trabalha com o Asterisk e estou usando o Asterisk-Java. Eu copiei e colei o exemplo do site e executei. Ele faz duas ligações. Eu atendo e fecha e faz outra ligação, dae só depois eu consigo ouvir a mensagem do Asterisk. Segue o código:
[code]public class HelloManager {
private ManagerConnection managerConnection;
public HelloManager() throws IOException {
ManagerConnectionFactory factory = new ManagerConnectionFactory(
"192.168.100.15", "manager", "senha");
this.managerConnection = factory.createManagerConnection();
}
public void run() throws IOException, AuthenticationFailedException,
TimeoutException {
OriginateAction originateAction;
ManagerResponse originateResponse;
originateAction = new OriginateAction();
originateAction.setCallerId("Teste");
originateAction.setChannel("SIP/2000");
originateAction.setContext("interno");
originateAction.setExten("2000");
originateAction.setPriority(1);
originateAction.setTimeout(30000L);
// 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
originateResponse = managerConnection.sendAction(originateAction, 30000);
// print out whether the originate succeeded or not
System.out.println(originateResponse.getResponse());
System.out.println(originateResponse.getMessage());
// and finally log off and disconnect
managerConnection.logoff();
}
public static void main(String[] args) throws Exception {
HelloManager helloManager;
helloManager = new HelloManager();
helloManager.run();
}
}[/code]
E a configuração do Asterisk, arquivo sip.conf
[2000]
type=friend
username=20
secret=senha
host=dynamic
mailbox=20
context=interno
canreinvite=yes
Arquivo extensions.conf
[interno]
exten => _20XX,1,Answer()
exten => _20XX,2,System(echo 'Pay me right now' | /usr/bin/text2wave -scale 1.5 -F 8000 -o /tmp/message.ulaw -otype ulaw)
exten => _20XX,3,Dial(SIP/${EXTEN},20,A(/tmp/message))
exten => _20XX,4,Hangup()
Ele funciona de um cliente SIP para outro, porém pelo Asterisk-Java acontece esse problema. Alguém sabe o que pode estar acontecendo?
Obrigado.