Java Examples ? Manager API

Hi,

Anyone got an example of the sendAction in Java ? I’ve searched all the sites etc, I would like to list all the current active channels. “show channels verbose”…

[code]…
managerConnection.login();

originateResponse = managerConnection.sendAction(“Action ??”, 3000);

managerConnection.logoff();
…[/code]

Thanks,
Rob

originateAction = new OriginateAction();
originateAction.setChannel(“Zap/4/9822490292”);
originateAction.setContext(“default”);
originateAction.setExten(“s”);
originateAction.setPriority(new Integer(2));
originateAction.setTimeout(new Integer(30000));

    //managerConnection.addEventHandler(new net.sf.asterisk.manager.event.DialEvent(){});
    // 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);

The sendAction method requires a OriginateAction reference and not String reference

try this:

asterisk-java.org/latest/apidocs … ction.html

You shouldn’t really post this in asterisk forums b’cause its not related to
asterisk but asterisk-java.

A general example is here: asterisk-java.org/latest/tutorial.html

To get a list of active channels have a look at the StatusAction and ManagerConnection’s sendEventGeneratingAction() method.

=Stefan