Title: Messaggio
The code is based on the sample program provided with asterisk-java tutorial, lightly customized to match my environment, and included in a jbuilder project; the class ManagerConnection belongs to asterisk-java-0.1.jar.
I think my problem is in your sentence: 'how is reading the response'; I found no other reference, in tutorial or in javadocs, about the way to read it; it may be that the ManagerResponse refers to the command itself, which effectively ends with success, and does not contain the extension status info: but then, where and how have I to search that data?
 
Anyway, this is the complete code of the program which should inquiry the status of an extension, together with its printout.
Newly thanks,
Franco.
 
===================
=== SOURCE CODE ===
===================
package astpac;
 
import java.io.*;
import net.sf.asterisk.manager.AuthenticationFailedException;
import net.sf.asterisk.manager.ManagerConnection;
import net.sf.asterisk.manager.ManagerConnectionFactory;
import net.sf.asterisk.manager.TimeoutException;
import net.sf.asterisk.manager.action.ExtensionStateAction;
import net.sf.asterisk.manager.response.ManagerResponse;
 
public class ProActions
{
    private ManagerConnection managerconnection;
    /*************************************************/
    public ProActions() throws IOException
    {
      try {
        ManagerConnectionFactory factory = new ManagerConnectionFactory();
        this.managerconnection = factory.getManagerConnection("172.16.1.151","admin","amp111");
      }
      catch(IOException ie) {
        System.out.println(ie.toString() + "[ProActions]");
      }
      catch(Exception e) {
        System.out.println(e.toString() + " [ProActions]");
      }
    }
    /*************************************************/
    public void run() throws IOException, AuthenticationFailedException,
            TimeoutException
    {
      try {
        ManagerResponse managerresponse;
        managerconnection.login();
          ExtensionStateAction extensionstateaction = new ExtensionStateAction();
          extensionstateaction.setExten("203");
          managerresponse = managerconnection.sendAction(extensionstateaction,30000);
          System.out.println(managerresponse.getResponse());
        }
        managerconnection.logoff();
      }
      catch (Exception e) {
        System.out.println(e.toString());
      }
    }
    /*************************************************/
    public static void main(String[] args) throws Exception
    {
        ProActions proactions = new ProActions();
        proactions.run();
    }
}
 
=======================================
=== OUTPUT GENERATED BY THE PROGRAM ===
=======================================
 
C:\JBuilder9\jdk1.4\bin\javaw -classpath
"C:\swdev\agsm\astproof\classes;C:\swdev\agsm\asterisk-java-0.1\asterisk-java-0.1.jar;C:\JBuilder9\jdk1.4\demo\jfc\Java
2D\Java2Demo.jar;C:\JBuilder9\jdk1.4\demo\plugin\jfc\Java2D\Java2Demo.jar;C:\JBuilder9\jdk1.4\jre\lib\charsets.jar;C:\JBuilder9\jdk1.4\jre\lib\ext\dnsns.jar;C:\JBuilder9\jdk1.4\jre\lib\ext\ldapsec.jar;C:\JBuilder9\jdk1.4\jre\lib\ext\localedata.jar;C:\JBuilder9\jdk1.4\jre\lib\ext\sunjce_provider.jar;C:\JBuilder9\jdk1.4\jre\lib\im\indicim.jar;C:\JBuilder9\jdk1.4\jre\lib\jaws.jar;C:\JBuilder9\jdk1.4\jre\lib\jce.jar;C:\JBuilder9\jdk1.4\jre\lib\jsse.jar;C:\JBuilder9\jdk1.4\jre\lib\rt.jar;C:\JBuilder9\jdk1.4\jre\lib\sunrsasign.jar;C:\JBuilder9\jdk1.4\lib\dt.jar;C:\JBuilder9\jdk1.4\lib\htmlconverter.jar;C:\JBuilder9\jdk1.4\lib\tools.jar"  -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=francobaldi-xp:1207,suspend=y astpac.ProActions
14-giu-2005 10.24.49 net.sf.asterisk.util.impl.JavaLoggingLog info
INFO: Connecting to 172.16.1.151 port 5038
14-giu-2005 10.24.50 net.sf.asterisk.util.impl.JavaLoggingLog info
INFO: Connected via Asterisk Call Manager/1.0
14-giu-2005 10.24.50 net.sf.asterisk.util.impl.JavaLoggingLog info
INFO: Successfully logged in
14-giu-2005 10.24.50 net.sf.asterisk.util.impl.JavaLoggingLog info
INFO: Reached end of stream, terminating reader.
net.sf.asterisk.manager.response.ManagerResponse: actionId='null'; message='Extension Status'; response='Success';
uniqueId='null'; systemHashcode=751354
14-giu-2005 10.24.50 net.sf.asterisk.util.impl.JavaLoggingLog info
INFO: Closing socket.
 
_______________________________________________
Asterisk-Dev mailing list
[email protected]
http://lists.digium.com/mailman/listinfo/asterisk-dev
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-dev

Reply via email to