Reputation: 1139
I am trying to run a script for asterisk-java
as below. I have added a main
method and calling the service
method inside it as follows:
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
{
public void service(AgiRequest request, AgiChannel channel)
throws AgiException
{
// Answer the channel...
answer();
// ...say hello...
streamFile("welcome");
// ...and hangup.
hangup();
}
public static void main (String[] args)
{
HelloAgiScript asteriskService = new HelloAgiScript();
asteriskService.service(request, channel);
}
}
When I try to compile it with the following command:
javac -cp asterisk-java.jar HelloAgiScript.java
I get this error:
HelloAgiScript.java:24: error: cannot find symbol
asteriskService.service(request, channel);
^
symbol: variable request
location: class HelloAgiScript
HelloAgiScript.java:24: error: channel has private access in AgiOperations
asteriskService.service(request, channel);
^
2 errors
How can I pass the arguments to the instance of the service
method inside the main
method?
Upvotes: 0
Views: 500
Reputation: 1120
You didn't put any parameters into your main method from the command line. You should write something like
javac -cp asterisk-java.jar par1, par2
But, first of all, you should define which parameter should be your inner parameter like
public static void main (String[] args)
{
HelloAgiScript asteriskService = new HelloAgiScript();
AgiRequest request = args[0];
AgiChannel channel = args[1];
asteriskService.service(request, channel);
}
Look here
Upvotes: -1
Reputation: 1304
You need to pass the argument as the object of AgiRequest
and AgiChannel
class to service()
method call.
As in your case both request
and channel
variable is not created. That's why you are getting error Can't find symbol
Your main method should be like this:
public static void main (String[] args)
{
HelloAgiScript asteriskService = new HelloAgiScript();
AgiRequest request = new AgiRequest();
AgiChannel channel = new AgiChannel();
asteriskService.service(request, channel);
}
Upvotes: 2