use of org.asteriskjava.manager.action.StatusAction in project openhab1-addons by openhab.
the class AsteriskBinding method connect.
/**
* Connects to <code>host</code> and opens a ManagerConnection by using the
* given <code>username</code> and <code>password</code>. Note: The Asterisk
* ManagerInterface on your Asterisk PBX is deactivated by default. Please
* refer to the documentation how to activate the ManagerInterface (AMI).
*
* @param host where to find the Asterisk PBX
* @param username username to login to Asterisk ManagerInterface
* @param password password to login to Asterisk ManagerInterface
*/
private void connect(String host, String username, String password) {
ManagerConnectionFactory factory = new ManagerConnectionFactory(host, username, password);
AsteriskBinding.managerConnection = factory.createManagerConnection();
AsteriskBinding.managerConnection.addEventListener(new AsteriskEventManager());
try {
AsteriskBinding.managerConnection.login();
} catch (AuthenticationFailedException afe) {
logger.error("Authentication failed. Please verify username and password.");
} catch (IOException ioe) {
logger.error("Could not connect to manager interface on host {}: {}", host, ioe);
} catch (Exception e) {
logger.error("Login to Asterisk manager interface on host {} threw an exception: {}", host, e);
}
try {
AsteriskBinding.managerConnection.sendAction(new StatusAction());
} catch (Exception e) {
logger.error("Registering for status update threw an exception: {}", e);
}
}
Aggregations