net.sf.asterisk.fastagi
Class AbstractAGIScript

java.lang.Object
  extended by net.sf.asterisk.fastagi.AbstractAGIScript
All Implemented Interfaces:
AGIScript

Deprecated. use BaseAGIScript instead

public abstract class AbstractAGIScript
extends java.lang.Object
implements AGIScript

The AbstractAGIScript provides some convinience methods to make it easier to write custom AGIScripts.
Just extend it by your own AGIScripts.

Version:
$Id: AbstractAGIScript.java,v 1.19 2005/11/27 15:22:40 srt Exp $
Author:
srt

Constructor Summary
AbstractAGIScript()
          Deprecated.  
 
Method Summary
protected  void answer(AGIChannel channel)
          Deprecated. Answers the channel.
protected  int exec(AGIChannel channel, java.lang.String application)
          Deprecated. Executes the given command.
protected  int exec(AGIChannel channel, java.lang.String application, java.lang.String options)
          Deprecated. Executes the given command.
protected  int execCommand(AGIChannel channel, java.lang.String application)
          Deprecated. use exec(AGIChannel, String) instead
protected  int execCommand(AGIChannel channel, java.lang.String application, java.lang.String options)
          Deprecated. use exec(AGIChannel, String, String) instead
protected  int getChannelStatus(AGIChannel channel)
          Deprecated. Returns the status of the channel.
Return values: 0 Channel is down and available 1 Channel is down, but reserved 2 Channel is off hook 3 Digits (or equivalent) have been dialed 4 Line is ringing 5 Remote end is ringing 6 Line is up 7 Line is busy
protected  java.lang.String getData(AGIChannel channel, java.lang.String file)
          Deprecated. Plays the given file and waits for the user to enter DTMF digits until he presses '#'.
protected  java.lang.String getData(AGIChannel channel, java.lang.String file, int timeout)
          Deprecated. Plays the given file and waits for the user to enter DTMF digits until he presses '#' or the timeout occurs.
protected  java.lang.String getData(AGIChannel channel, java.lang.String file, int timeout, int maxDigits)
          Deprecated. Plays the given file and waits for the user to enter DTMF digits until he presses '#' or the timeout occurs or the maximum number of digits has been entered.
protected  char getOption(AGIChannel channel, java.lang.String file, java.lang.String escapeDigits)
          Deprecated. Plays the given file, and waits for the user to press one of the given digits.
protected  char getOption(AGIChannel channel, java.lang.String file, java.lang.String escapeDigits, int timeout)
          Deprecated. Plays the given file, and waits for the user to press one of the given digits.
protected  java.lang.String getVariable(AGIChannel channel, java.lang.String name)
          Deprecated. Returns the value of the given channel variable.
protected  void hangup(AGIChannel channel)
          Deprecated. Hangs the channel up.
protected  void playMusicOnHold(AGIChannel channel)
          Deprecated. Plays music on hold from the default music on hold class.
protected  void playMusicOnHold(AGIChannel channel, java.lang.String musicOnHoldClass)
          Deprecated. Plays music on hold from the given music on hold class.
protected  void sayAlpha(AGIChannel channel, java.lang.String text)
          Deprecated. Says the given character string.
protected  char sayAlpha(AGIChannel channel, java.lang.String text, java.lang.String escapeDigits)
          Deprecated. Says the given character string, returning early if any of the given DTMF number are received on the channel.
protected  void sayDigits(AGIChannel channel, java.lang.String digits)
          Deprecated. Says the given digit string.
protected  char sayDigits(AGIChannel channel, java.lang.String digits, java.lang.String escapeDigits)
          Deprecated. Says the given number, returning early if any of the given DTMF number are received on the channel.
protected  void sayNumber(AGIChannel channel, java.lang.String number)
          Deprecated. Says the given number.
protected  char sayNumber(AGIChannel channel, java.lang.String number, java.lang.String escapeDigits)
          Deprecated. Says the given number, returning early if any of the given DTMF number are received on the channel.
protected  void sayPhonetic(AGIChannel channel, java.lang.String text)
          Deprecated. Says the given character string with phonetics.
protected  char sayPhonetic(AGIChannel channel, java.lang.String text, java.lang.String escapeDigits)
          Deprecated. Says the given character string with phonetics, returning early if any of the given DTMF number are received on the channel.
protected  void sayTime(AGIChannel channel, long time)
          Deprecated. Says the given time.
protected  char sayTime(AGIChannel channel, long time, java.lang.String escapeDigits)
          Deprecated. Says the given time, returning early if any of the given DTMF number are received on the channel.
protected  void setAutoHangup(AGIChannel channel, int time)
          Deprecated. Cause the channel to automatically hangup at the given number of seconds in the future.
protected  void setCallerId(AGIChannel channel, java.lang.String callerId)
          Deprecated. Sets the caller id on the current channel.
protected  void setContext(AGIChannel channel, java.lang.String context)
          Deprecated. Sets the context for continuation upon exiting the application.
protected  void setExtension(AGIChannel channel, java.lang.String extension)
          Deprecated. Sets the extension for continuation upon exiting the application.
protected  void setPriority(AGIChannel channel, java.lang.String priority)
          Deprecated. Sets the priority or label for continuation upon exiting the application.
protected  void setVariable(AGIChannel channel, java.lang.String name, java.lang.String value)
          Deprecated. Sets the value of the given channel variable to a new value.
protected  void stopMusicOnHold(AGIChannel channel)
          Deprecated. Stops playing music on hold.
protected  void streamFile(AGIChannel channel, java.lang.String file)
          Deprecated. Plays the given file.
protected  char streamFile(AGIChannel channel, java.lang.String file, java.lang.String escapeDigits)
          Deprecated. Plays the given file and allows the user to escape by pressing one of the given digit.
protected  char waitForDigit(AGIChannel channel, int timeout)
          Deprecated. Waits up to 'timeout' milliseconds to receive a DTMF digit.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.sf.asterisk.fastagi.AGIScript
service
 

Constructor Detail

AbstractAGIScript

public AbstractAGIScript()
Deprecated. 
Method Detail

answer

protected void answer(AGIChannel channel)
               throws AGIException
Deprecated. 
Answers the channel.

Throws:
AGIException

hangup

protected void hangup(AGIChannel channel)
               throws AGIException
Deprecated. 
Hangs the channel up.

Throws:
AGIException

setAutoHangup

protected void setAutoHangup(AGIChannel channel,
                             int time)
                      throws AGIException
Deprecated. 
Cause the channel to automatically hangup at the given number of seconds in the future.

Parameters:
time - the number of seconds before this channel is automatically hung up.
0 disables the autohangup feature.
Throws:
AGIException

setCallerId

protected void setCallerId(AGIChannel channel,
                           java.lang.String callerId)
                    throws AGIException
Deprecated. 
Sets the caller id on the current channel.

Parameters:
callerId - the raw caller id to set, for example "John Doe<1234>".
Throws:
AGIException

playMusicOnHold

protected void playMusicOnHold(AGIChannel channel)
                        throws AGIException
Deprecated. 
Plays music on hold from the default music on hold class.

Throws:
AGIException

playMusicOnHold

protected void playMusicOnHold(AGIChannel channel,
                               java.lang.String musicOnHoldClass)
                        throws AGIException
Deprecated. 
Plays music on hold from the given music on hold class.

Parameters:
musicOnHoldClass - the music on hold class to play music from as configures in Asterisk's .
Throws:
AGIException

stopMusicOnHold

protected void stopMusicOnHold(AGIChannel channel)
                        throws AGIException
Deprecated. 
Stops playing music on hold.

Throws:
AGIException

getChannelStatus

protected int getChannelStatus(AGIChannel channel)
                        throws AGIException
Deprecated. 
Returns the status of the channel.
Return values:
  • 0 Channel is down and available
  • 1 Channel is down, but reserved
  • 2 Channel is off hook
  • 3 Digits (or equivalent) have been dialed
  • 4 Line is ringing
  • 5 Remote end is ringing
  • 6 Line is up
  • 7 Line is busy

Returns:
the status of the channel.
Throws:
AGIException

getData

protected java.lang.String getData(AGIChannel channel,
                                   java.lang.String file)
                            throws AGIException
Deprecated. 
Plays the given file and waits for the user to enter DTMF digits until he presses '#'. The user may interrupt the streaming by starting to enter digits.

Parameters:
file - the name of the file to play
Returns:
a String containing the DTMF the user entered
Throws:
AGIException
Since:
0.2

getData

protected java.lang.String getData(AGIChannel channel,
                                   java.lang.String file,
                                   int timeout)
                            throws AGIException
Deprecated. 
Plays the given file and waits for the user to enter DTMF digits until he presses '#' or the timeout occurs. The user may interrupt the streaming by starting to enter digits.

Parameters:
file - the name of the file to play
timeout - the timeout to wait for user input.
0 means standard timeout value, -1 means "ludicrous time" (essentially never times out).
Returns:
a String containing the DTMF the user entered
Throws:
AGIException
Since:
0.2

getData

protected java.lang.String getData(AGIChannel channel,
                                   java.lang.String file,
                                   int timeout,
                                   int maxDigits)
                            throws AGIException
Deprecated. 
Plays the given file and waits for the user to enter DTMF digits until he presses '#' or the timeout occurs or the maximum number of digits has been entered. The user may interrupt the streaming by starting to enter digits.

Parameters:
file - the name of the file to play
timeout - the timeout to wait for user input.
0 means standard timeout value, -1 means "ludicrous time" (essentially never times out).
maxDigits - the maximum number of digits the user is allowed to enter
Returns:
a String containing the DTMF the user entered
Throws:
AGIException
Since:
0.2

getOption

protected char getOption(AGIChannel channel,
                         java.lang.String file,
                         java.lang.String escapeDigits)
                  throws AGIException
Deprecated. 
Plays the given file, and waits for the user to press one of the given digits. If none of the esacpe digits is pressed while streaming the file it waits for the default timeout of 5 seconds still waiting for the user to press a digit.

Parameters:
file - the name of the file to stream, must not include extension.
escapeDigits - contains the digits that the user is expected to press.
Returns:
the DTMF digit pressed or 0x0 if none was pressed.
Throws:
AGIException

getOption

protected char getOption(AGIChannel channel,
                         java.lang.String file,
                         java.lang.String escapeDigits,
                         int timeout)
                  throws AGIException
Deprecated. 
Plays the given file, and waits for the user to press one of the given digits. If none of the esacpe digits is pressed while streaming the file it waits for the specified timeout still waiting for the user to press a digit.

Parameters:
file - the name of the file to stream, must not include extension.
escapeDigits - contains the digits that the user is expected to press.
timeout - the timeout in seconds to wait if none of the defined esacpe digits was presses while streaming.
Returns:
the DTMF digit pressed or 0x0 if none was pressed.
Throws:
AGIException

exec

protected int exec(AGIChannel channel,
                   java.lang.String application)
            throws AGIException
Deprecated. 
Executes the given command.

Parameters:
application - the name of the application to execute, for example "Dial".
Returns:
the return code of the application of -2 if the application was not found.
Throws:
AGIException
Since:
0.2

exec

protected int exec(AGIChannel channel,
                   java.lang.String application,
                   java.lang.String options)
            throws AGIException
Deprecated. 
Executes the given command.

Parameters:
application - the name of the application to execute, for example "Dial".
options - the parameters to pass to the application, for example "SIP/123".
Returns:
the return code of the application of -2 if the application was not found.
Throws:
AGIException
Since:
0.2

execCommand

protected int execCommand(AGIChannel channel,
                          java.lang.String application)
                   throws AGIException
Deprecated. use exec(AGIChannel, String) instead

Executes the given command.

Parameters:
application - the name of the application to execute, for example "Dial".
Returns:
the return code of the application of -2 if the application was not found.
Throws:
AGIException

execCommand

protected int execCommand(AGIChannel channel,
                          java.lang.String application,
                          java.lang.String options)
                   throws AGIException
Deprecated. use exec(AGIChannel, String, String) instead

Executes the given command.

Parameters:
application - the name of the application to execute, for example "Dial".
options - the parameters to pass to the application, for example "SIP/123".
Returns:
the return code of the application of -2 if the application was not found.
Throws:
AGIException

setContext

protected void setContext(AGIChannel channel,
                          java.lang.String context)
                   throws AGIException
Deprecated. 
Sets the context for continuation upon exiting the application.

Parameters:
context - the context for continuation upon exiting the application.
Throws:
AGIException

setExtension

protected void setExtension(AGIChannel channel,
                            java.lang.String extension)
                     throws AGIException
Deprecated. 
Sets the extension for continuation upon exiting the application.

Parameters:
extension - the extension for continuation upon exiting the application.
Throws:
AGIException

setPriority

protected void setPriority(AGIChannel channel,
                           java.lang.String priority)
                    throws AGIException
Deprecated. 
Sets the priority or label for continuation upon exiting the application.

Parameters:
priority - the priority or label for continuation upon exiting the application.
Throws:
AGIException

streamFile

protected void streamFile(AGIChannel channel,
                          java.lang.String file)
                   throws AGIException
Deprecated. 
Plays the given file.

Parameters:
file - name of the file to play.
Throws:
AGIException

streamFile

protected char streamFile(AGIChannel channel,
                          java.lang.String file,
                          java.lang.String escapeDigits)
                   throws AGIException
Deprecated. 
Plays the given file and allows the user to escape by pressing one of the given digit.

Parameters:
file - name of the file to play.
escapeDigits - a String containing the DTMF digits that allow the user to escape.
Returns:
the DTMF digit pressed or 0x0 if none was pressed.
Throws:
AGIException

sayDigits

protected void sayDigits(AGIChannel channel,
                         java.lang.String digits)
                  throws AGIException
Deprecated. 
Says the given digit string.

Parameters:
digits - the digit string to say.
Throws:
AGIException

sayDigits

protected char sayDigits(AGIChannel channel,
                         java.lang.String digits,
                         java.lang.String escapeDigits)
                  throws AGIException
Deprecated. 
Says the given number, returning early if any of the given DTMF number are received on the channel.

Parameters:
digits - the digit string to say.
escapeDigits - a String containing the DTMF digits that allow the user to escape.
Returns:
the DTMF digit pressed or 0x0 if none was pressed.
Throws:
AGIException

sayNumber

protected void sayNumber(AGIChannel channel,
                         java.lang.String number)
                  throws AGIException
Deprecated. 
Says the given number.

Parameters:
number - the number to say.
Throws:
AGIException

sayNumber

protected char sayNumber(AGIChannel channel,
                         java.lang.String number,
                         java.lang.String escapeDigits)
                  throws AGIException
Deprecated. 
Says the given number, returning early if any of the given DTMF number are received on the channel.

Parameters:
number - the number to say.
escapeDigits - a String containing the DTMF digits that allow the user to escape.
Returns:
the DTMF digit pressed or 0x0 if none was pressed.
Throws:
AGIException

sayPhonetic

protected void sayPhonetic(AGIChannel channel,
                           java.lang.String text)
                    throws AGIException
Deprecated. 
Says the given character string with phonetics.

Parameters:
text - the text to say.
Throws:
AGIException

sayPhonetic

protected char sayPhonetic(AGIChannel channel,
                           java.lang.String text,
                           java.lang.String escapeDigits)
                    throws AGIException
Deprecated. 
Says the given character string with phonetics, returning early if any of the given DTMF number are received on the channel.

Parameters:
text - the text to say.
escapeDigits - a String containing the DTMF digits that allow the user to escape.
Returns:
the DTMF digit pressed or 0x0 if none was pressed.
Throws:
AGIException

sayAlpha

protected void sayAlpha(AGIChannel channel,
                        java.lang.String text)
                 throws AGIException
Deprecated. 
Says the given character string.

Parameters:
text - the text to say.
Throws:
AGIException

sayAlpha

protected char sayAlpha(AGIChannel channel,
                        java.lang.String text,
                        java.lang.String escapeDigits)
                 throws AGIException
Deprecated. 
Says the given character string, returning early if any of the given DTMF number are received on the channel.

Parameters:
text - the text to say.
escapeDigits - a String containing the DTMF digits that allow the user to escape.
Returns:
the DTMF digit pressed or 0x0 if none was pressed.
Throws:
AGIException

sayTime

protected void sayTime(AGIChannel channel,
                       long time)
                throws AGIException
Deprecated. 
Says the given time.

Parameters:
time - the time to say in seconds since 00:00:00 on January 1, 1970.
Throws:
AGIException

sayTime

protected char sayTime(AGIChannel channel,
                       long time,
                       java.lang.String escapeDigits)
                throws AGIException
Deprecated. 
Says the given time, returning early if any of the given DTMF number are received on the channel.

Parameters:
time - the time to say in seconds since 00:00:00 on January 1, 1970.
escapeDigits - a String containing the DTMF digits that allow the user to escape.
Returns:
the DTMF digit pressed or 0x0 if none was pressed.
Throws:
AGIException

getVariable

protected java.lang.String getVariable(AGIChannel channel,
                                       java.lang.String name)
                                throws AGIException
Deprecated. 
Returns the value of the given channel variable.

Parameters:
name - the name of the variable to retrieve.
Returns:
the value of the given variable or null if not set.
Throws:
AGIException

setVariable

protected void setVariable(AGIChannel channel,
                           java.lang.String name,
                           java.lang.String value)
                    throws AGIException
Deprecated. 
Sets the value of the given channel variable to a new value.

Parameters:
name - the name of the variable to retrieve.
value - the new value to set.
Throws:
AGIException

waitForDigit

protected char waitForDigit(AGIChannel channel,
                            int timeout)
                     throws AGIException
Deprecated. 
Waits up to 'timeout' milliseconds to receive a DTMF digit.

Parameters:
timeout - timeout the milliseconds to wait for the channel to receive a DTMF digit, -1 will wait forever.
Returns:
the DTMF digit pressed or 0x0 if none was pressed.
Throws:
AGIException


Copyright © 2004-2005 Stefan Reuter. All Rights Reserved.