0

質問はそれ自体を物語っています。fastagi.AgiChannel の getoption メソッドを実行したいのですが、ダイヤルプランで Background(press-1&or&press-2) を直接実行するように、連結プロンプトを使用します。私はすべてのバリエーションを試し、ネット上のあらゆる場所を検索しましたが、見つかりませんでした. 私はEclipseを使用してJavaでプログラミングしています。コードの下。

import org.asteriskjava.fastagi.AgiChannel;
import org.asteriskjava.fastagi.AgiException;
import org.asteriskjava.fastagi.AgiRequest;
import org.asteriskjava.fastagi.BaseAgiScript;

public class HelloAgiScript extends BaseAgiScript{

    @Override
    public void service(AgiRequest arg0, AgiChannel arg1) throws AgiException {
        int choice;
        // Answer the channel
        answer();
        //say hello
        streamFile("silence/1");
        streamFile("welcome");
        //Ask for an input and give feedback
        choice=getOption("press-1","1,2"); //Here is where I would like to prompt press-1 or press-2
        sayDigits(String.valueOf(choice-48));
        streamFile("silence/1");
        //and hangup
        hangup();   
    }
    }
4

2 に答える 2

0

解決策を見つけました。arehops が示唆しているように、複数のファイルで getOption を使用することはできません。彼の提案を再現することはできませんでしたが、exec と AgiReply を使用して、この実装が機能することがわかりました。

import org.asteriskjava.fastagi.AgiChannel;
import org.asteriskjava.fastagi.AgiException;
import org.asteriskjava.fastagi.AgiRequest;
import org.asteriskjava.fastagi.BaseAgiScript;
import org.asteriskjava.fastagi.reply.AgiReply;

public class HelloAgiScript extends BaseAgiScript {

    @Override
    public void service(AgiRequest arg0, AgiChannel arg1) throws AgiException {
        String choice;
        // Answer the channel
        answer();
        //say hello
        streamFile("silence/1");
        streamFile("welcome");
        //Ask for an input and give feedback
        System.out.println("test");
        exec("Background","press-1&or&press-2&silence/3"); //Executes Background application
        AgiReply agiReply = getLastReply(); //Get the reply in the form of an AgiReply object
        choice=agiReply.getResult(); //Extract the actual reply
        choice=Character.toString((char) Integer.parseInt(choice)); // convert from ascii to actual digit
        System.out.println("choice: "+choice);
        streamFile("silence/1");
        sayDigits(choice);
        streamFile("silence/1");
        //and hangup
        hangup();   
    }
}
于 2014-01-09T12:19:35.623 に答える