I chose to generate the connection through Asteriskserver, because the asteriskserver is followed by the change of the listening call properties.
Demo
Asteriskserver asteriskserver=new defaultasteriskserver ("Server IP", "account", "password");
if (asteriskserver!=null) {
Managerconnection conn=asteriskserver.getmanagerconnection ();
Conn.login ();//server connection
}
You can put the connection object in the cache and pull it out to close it.
Mapcacheutil instance=mapcacheutil.getinstance ();//Get Cached objects
Managerconnection conn= (managerconnection) instance.get (baseutil.connection_centent);
if (conn!=null) {
Conn.logoff ();
}
Currently I am app start, open connection, close connection when off. Seemingly can also be a user soft login, open a new connection, you can try it yourself.
Asterisk-java Ami Getting started, connecting and shutting down the server