Upgrade 3CX to v18 and get it hosted free!

Asterisk manager Example: Java

Author image

Asterisk Manager Example: Java

 

Java library

The Asterisk-java package (available unter Apache License from http://asterisk-java.org/) consists of a set of Java classes that allow you to use the Manager API Java applications.

It supports receiving events from the Asterisk server (e.g. call progess, registered peers, channel state) and sending actions to Asterisk (e.g. originate call, agent login/logoff, start/stop voice recording).

Example:

public class TestDefaultManagerConnection extends TestCase
{
private DefaultManagerConnection getDefaultManagerConnection()
{
DefaultManagerConnection dmc;

dmc = new DefaultManagerConnection();
dmc.setUsername(“username”);
dmc.setPassword(“password”);
dmc.setHostname(“localhost”);

return dmc;
}

public void testLogin() throws Exception
{
DefaultManagerConnection dmc;

dmc = getDefaultManagerConnection();
dmc.login();
dmc.addEventHandler(new ManagerEventHandler()
{
public void handleEvent(ManagerEvent event)
{
System.out.println(event);
}
});
dmc.sendAction(new StatusAction());

// wait for 3 seconds to receive events
Thread.sleep(3000);
dmc.logoff();
}
}

 

Back

Related Posts:

Get 3CX - Absolutely Free!
Link up your team and customers Phone System Live Chat Video Conferencing

Hosted or Self-managed. Up to 10 users free forever. No credit card. Try risk free.

3CX
A 3CX Account with that email already exists. You will be redirected to the Customer Portal to sign in or reset your password if you've forgotten it.