|
Asterisk-Java | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.asteriskjava.fastagi.BaseAgiScript
public abstract class BaseAgiScript
The BaseAgiScript provides some convinience methods to make it easier to
write custom AgiScripts.
Just extend it by your own script classes.
| Constructor Summary | |
|---|---|
BaseAgiScript()
|
|
| Method Summary | |
|---|---|
protected void |
answer()
Answers the channel. |
protected void |
controlStreamFile(java.lang.String file)
Plays the given file allowing the user to control the streaming by using "#" for forward and "*" for rewind. |
protected char |
controlStreamFile(java.lang.String file,
java.lang.String escapeDigits)
Plays the given file allowing the user to control the streaming by using "#" for forward and "*" for rewind. |
protected char |
controlStreamFile(java.lang.String file,
java.lang.String escapeDigits,
int offset)
Plays the given file allowing the user to control the streaming by using "#" for forward and "*" for rewind. |
protected char |
controlStreamFile(java.lang.String file,
java.lang.String escapeDigits,
int offset,
java.lang.String forwardDigit,
java.lang.String rewindDigit,
java.lang.String pauseDigit)
Plays the given file allowing the user to control the streaming by using forwardDigit for forward, rewindDigit for rewind and pauseDigit for pause. |
protected void |
databaseDel(java.lang.String family,
java.lang.String key)
Deletes an entry in the Asterisk database for a given family and key. |
protected void |
databaseDelTree(java.lang.String family)
Deletes a whole family of entries in the Asterisk database. |
protected void |
databaseDelTree(java.lang.String family,
java.lang.String keytree)
Deletes all entries of a given family in the Asterisk database that have a key that starts with a given prefix. |
protected java.lang.String |
databaseGet(java.lang.String family,
java.lang.String key)
Retrieves an entry in the Asterisk database for a given family and key. |
protected void |
databasePut(java.lang.String family,
java.lang.String key,
java.lang.String value)
Adds or updates an entry in the Asterisk database for a given family, key, and value. |
protected int |
exec(java.lang.String application)
Executes the given command. |
protected int |
exec(java.lang.String application,
java.lang.String options)
Executes the given command. |
protected int |
getChannelStatus()
Returns the status of the channel. |
protected java.lang.String |
getData(java.lang.String file)
Plays the given file and waits for the user to enter DTMF digits until he presses '#'. |
protected java.lang.String |
getData(java.lang.String file,
int timeout)
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(java.lang.String file,
int timeout,
int maxDigits)
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 java.lang.String |
getFullVariable(java.lang.String name)
Returns the value of the current channel variable, unlike getVariable() this method understands complex variable names and builtin variables. |
protected java.lang.String |
getFullVariable(java.lang.String name,
java.lang.String channel)
Returns the value of the given channel variable. |
protected char |
getOption(java.lang.String file,
java.lang.String escapeDigits)
Plays the given file, and waits for the user to press one of the given digits. |
protected char |
getOption(java.lang.String file,
java.lang.String escapeDigits,
int timeout)
Plays the given file, and waits for the user to press one of the given digits. |
protected java.lang.String |
getVariable(java.lang.String name)
Returns the value of the given channel variable. |
protected void |
hangup()
Hangs the channel up. |
protected void |
playMusicOnHold()
Plays music on hold from the default music on hold class. |
protected void |
playMusicOnHold(java.lang.String musicOnHoldClass)
Plays music on hold from the given music on hold class. |
protected void |
recordFile(java.lang.String file,
java.lang.String format,
java.lang.String escapeDigits,
int timeout)
Record to a file until a given dtmf digit in the sequence is received. |
protected void |
recordFile(java.lang.String file,
java.lang.String format,
java.lang.String escapeDigits,
int timeout,
int offset,
boolean beep,
int maxSilence)
Record to a file until a given dtmf digit in the sequence is received. |
protected void |
sayAlpha(java.lang.String text)
Says the given character string. |
protected char |
sayAlpha(java.lang.String text,
java.lang.String escapeDigits)
Says the given character string, returning early if any of the given DTMF number are received on the channel. |
protected void |
sayDateTime(long time)
Says the given time. |
protected char |
sayDateTime(long time,
java.lang.String escapeDigits)
Says the given time and allows interruption by one of the given escape digits. |
protected char |
sayDateTime(long time,
java.lang.String escapeDigits,
java.lang.String format)
Says the given time in the given format and allows interruption by one of the given escape digits. |
protected char |
sayDateTime(long time,
java.lang.String escapeDigits,
java.lang.String format,
java.lang.String timezone)
Says the given time in the given format and timezone and allows interruption by one of the given escape digits. |
protected void |
sayDigits(java.lang.String digits)
Says the given digit string. |
protected char |
sayDigits(java.lang.String digits,
java.lang.String escapeDigits)
Says the given number, returning early if any of the given DTMF number are received on the channel. |
protected void |
sayNumber(java.lang.String number)
Says the given number. |
protected char |
sayNumber(java.lang.String number,
java.lang.String escapeDigits)
Says the given number, returning early if any of the given DTMF number are received on the channel. |
protected void |
sayPhonetic(java.lang.String text)
Says the given character string with phonetics. |
protected char |
sayPhonetic(java.lang.String text,
java.lang.String escapeDigits)
Says the given character string with phonetics, returning early if any of the given DTMF number are received on the channel. |
protected void |
sayTime(long time)
Says the given time. |
protected char |
sayTime(long time,
java.lang.String escapeDigits)
Says the given time, returning early if any of the given DTMF number are received on the channel. |
protected void |
setAutoHangup(int time)
Cause the channel to automatically hangup at the given number of seconds in the future. |
protected void |
setCallerId(java.lang.String callerId)
Sets the caller id on the current channel. |
protected void |
setContext(java.lang.String context)
Sets the context for continuation upon exiting the application. |
protected void |
setExtension(java.lang.String extension)
Sets the extension for continuation upon exiting the application. |
protected void |
setPriority(java.lang.String priority)
Sets the priority or label for continuation upon exiting the application. |
protected void |
setVariable(java.lang.String name,
java.lang.String value)
Sets the value of the given channel variable to a new value. |
protected void |
stopMusicOnHold()
Stops playing music on hold. |
protected void |
streamFile(java.lang.String file)
Plays the given file. |
protected char |
streamFile(java.lang.String file,
java.lang.String escapeDigits)
Plays the given file and allows the user to escape by pressing one of the given digit. |
protected void |
verbose(java.lang.String message,
int level)
Sends a message to the Asterisk console via the verbose message system. |
protected char |
waitForDigit(int timeout)
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 org.asteriskjava.fastagi.AgiScript |
|---|
service |
| Constructor Detail |
|---|
public BaseAgiScript()
| Method Detail |
|---|
protected void answer()
throws AgiException
AgiException
protected void hangup()
throws AgiException
AgiException
protected void setAutoHangup(int time)
throws AgiException
time - the number of seconds before this channel is automatically
hung up.0 disables the autohangup feature.
AgiException
protected void setCallerId(java.lang.String callerId)
throws AgiException
callerId - the raw caller id to set, for example "John Doe<1234>".
AgiException
protected void playMusicOnHold()
throws AgiException
AgiException
protected void playMusicOnHold(java.lang.String musicOnHoldClass)
throws AgiException
musicOnHoldClass - the music on hold class to play music from as
configures in Asterisk's .
- Throws:
AgiException
protected void stopMusicOnHold()
throws AgiException
AgiException
protected int getChannelStatus()
throws AgiException
Return values:
AgiException
protected java.lang.String getData(java.lang.String file)
throws AgiException
file - the name of the file to play
AgiException
protected java.lang.String getData(java.lang.String file,
int timeout)
throws AgiException
file - the name of the file to playtimeout - the timeout in milliseconds to wait for user input.0 means standard timeout value, -1 means "ludicrous time" (essentially never times out).
AgiException
protected java.lang.String getData(java.lang.String file,
int timeout,
int maxDigits)
throws AgiException
file - the name of the file to playtimeout - the timeout in milliseconds 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
AgiException
protected char getOption(java.lang.String file,
java.lang.String escapeDigits)
throws AgiException
file - the name of the file to stream, must not include extension.escapeDigits - contains the digits that the user is expected to
press.
AgiException
protected char getOption(java.lang.String file,
java.lang.String escapeDigits,
int timeout)
throws AgiException
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.
AgiException
protected int exec(java.lang.String application)
throws AgiException
application - the name of the application to execute, for example
"Dial".
AgiException
protected int exec(java.lang.String application,
java.lang.String options)
throws AgiException
application - the name of the application to execute, for example
"Dial".options - the parameters to pass to the application, for example
"SIP/123". Multiple options are separated by the pipe character ('|').
AgiException
protected void setContext(java.lang.String context)
throws AgiException
context - the context for continuation upon exiting the application.
AgiException
protected void setExtension(java.lang.String extension)
throws AgiException
extension - the extension for continuation upon exiting the
application.
AgiException
protected void setPriority(java.lang.String priority)
throws AgiException
priority - the priority or label for continuation upon exiting the
application.
AgiException
protected void streamFile(java.lang.String file)
throws AgiException
file - name of the file to play.
AgiException
protected char streamFile(java.lang.String file,
java.lang.String escapeDigits)
throws AgiException
file - name of the file to play.escapeDigits - a String containing the DTMF digits that allow the
user to escape.
AgiException
protected void sayDigits(java.lang.String digits)
throws AgiException
digits - the digit string to say.
AgiException
protected char sayDigits(java.lang.String digits,
java.lang.String escapeDigits)
throws AgiException
digits - the digit string to say.escapeDigits - a String containing the DTMF digits that allow the
user to escape.
AgiException
protected void sayNumber(java.lang.String number)
throws AgiException
number - the number to say.
AgiException
protected char sayNumber(java.lang.String number,
java.lang.String escapeDigits)
throws AgiException
number - the number to say.escapeDigits - a String containing the DTMF digits that allow the
user to escape.
AgiException
protected void sayPhonetic(java.lang.String text)
throws AgiException
text - the text to say.
AgiException
protected char sayPhonetic(java.lang.String text,
java.lang.String escapeDigits)
throws AgiException
text - the text to say.escapeDigits - a String containing the DTMF digits that allow the
user to escape.
AgiException
protected void sayAlpha(java.lang.String text)
throws AgiException
text - the text to say.
AgiException
protected char sayAlpha(java.lang.String text,
java.lang.String escapeDigits)
throws AgiException
text - the text to say.escapeDigits - a String containing the DTMF digits that allow the
user to escape.
AgiException
protected void sayTime(long time)
throws AgiException
time - the time to say in seconds since 00:00:00 on January 1, 1970.
AgiException
protected char sayTime(long time,
java.lang.String escapeDigits)
throws AgiException
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.
AgiException
protected java.lang.String getVariable(java.lang.String name)
throws AgiException
name - the name of the variable to retrieve.
null if not
set.
AgiException
protected void setVariable(java.lang.String name,
java.lang.String value)
throws AgiException
name - the name of the variable to retrieve.value - the new value to set.
AgiException
protected char waitForDigit(int timeout)
throws AgiException
timeout - timeout the milliseconds to wait for the channel to
receive a DTMF digit, -1 will wait forever.
AgiException
protected java.lang.String getFullVariable(java.lang.String name)
throws AgiException
You can also use this method to use custom Asterisk functions. Syntax is "func(args)".
Available since Asterisk 1.2.
name - the name of the variable to retrieve.
null if not
set.
AgiException
protected java.lang.String getFullVariable(java.lang.String name,
java.lang.String channel)
throws AgiException
Available since Asterisk 1.2.
name - the name of the variable to retrieve.channel - the name of the channel.
null if not
set.
AgiException
protected void sayDateTime(long time)
throws AgiException
Available since Asterisk 1.2.
time - the time to say in seconds elapsed since 00:00:00 on January
1, 1970, Coordinated Universal Time (UTC)
AgiException
protected char sayDateTime(long time,
java.lang.String escapeDigits)
throws AgiException
Available since Asterisk 1.2.
time - the time to say in seconds elapsed since 00:00:00 on January
1, 1970, Coordinated Universal Time (UTC)escapeDigits - the digits that allow the user to interrupt this
command or null for none.
AgiException
protected char sayDateTime(long time,
java.lang.String escapeDigits,
java.lang.String format)
throws AgiException
Available since Asterisk 1.2.
time - the time to say in seconds elapsed since 00:00:00 on January
1, 1970, Coordinated Universal Time (UTC)escapeDigits - the digits that allow the user to interrupt this
command or null for none.format - the format the time should be said in
AgiException
protected char sayDateTime(long time,
java.lang.String escapeDigits,
java.lang.String format,
java.lang.String timezone)
throws AgiException
Available since Asterisk 1.2.
time - the time to say in seconds elapsed since 00:00:00 on January
1, 1970, Coordinated Universal Time (UTC)escapeDigits - the digits that allow the user to interrupt this
command or null for none.format - the format the time should be said intimezone - the timezone to use when saying the time, for example
"UTC" or "Europe/Berlin".
AgiException
protected java.lang.String databaseGet(java.lang.String family,
java.lang.String key)
throws AgiException
family - the family of the entry to retrieve.key - the key of the entry to retrieve.
null if there
is no such value.
AgiException
protected void databasePut(java.lang.String family,
java.lang.String key,
java.lang.String value)
throws AgiException
family - the family of the entry to add or update.key - the key of the entry to add or update.value - the new value of the entry.
AgiException
protected void databaseDel(java.lang.String family,
java.lang.String key)
throws AgiException
family - the family of the entry to delete.key - the key of the entry to delete.
AgiException
protected void databaseDelTree(java.lang.String family)
throws AgiException
family - the family to delete.
AgiException
protected void databaseDelTree(java.lang.String family,
java.lang.String keytree)
throws AgiException
family - the family of the entries to delete.keytree - the prefix of the keys of the entries to delete.
AgiException
protected void verbose(java.lang.String message,
int level)
throws AgiException
message - the message to send.level - the verbosity level to use. Must be in [1..4].
AgiException
protected void recordFile(java.lang.String file,
java.lang.String format,
java.lang.String escapeDigits,
int timeout)
throws AgiException
file - the name of the file to stream, must not include extension.format - the format of the file to be recorded, for example "wav".escapeDigits - contains the digits that allow the user to end
recording.timeout - the maximum record time in milliseconds, or -1 for no
timeout.
AgiException
protected void recordFile(java.lang.String file,
java.lang.String format,
java.lang.String escapeDigits,
int timeout,
int offset,
boolean beep,
int maxSilence)
throws AgiException
file - the name of the file to stream, must not include extension.format - the format of the file to be recorded, for example "wav".escapeDigits - contains the digits that allow the user to end
recording.timeout - the maximum record time in milliseconds, or -1 for no
timeout.offset - the offset samples to skip.beep - true if a beep should be played before
recording.maxSilence - The amount of silence (in seconds) to allow before
returning despite the lack of dtmf digits or reaching timeout.
AgiException
protected void controlStreamFile(java.lang.String file)
throws AgiException
file - the name of the file to stream, must not include extension.
AgiException
protected char controlStreamFile(java.lang.String file,
java.lang.String escapeDigits)
throws AgiException
file - the name of the file to stream, must not include extension.escapeDigits - contains the digits that allow the user to interrupt
this command.
AgiException
protected char controlStreamFile(java.lang.String file,
java.lang.String escapeDigits,
int offset)
throws AgiException
file - the name of the file to stream, must not include extension.escapeDigits - contains the digits that allow the user to interrupt
this command. May be null if you don't want the
user to interrupt.offset - the offset samples to skip before streaming.
AgiException
protected char controlStreamFile(java.lang.String file,
java.lang.String escapeDigits,
int offset,
java.lang.String forwardDigit,
java.lang.String rewindDigit,
java.lang.String pauseDigit)
throws AgiException
file - the name of the file to stream, must not include extension.escapeDigits - contains the digits that allow the user to interrupt
this command. May be null if you don't want the
user to interrupt.offset - the offset samples to skip before streaming, use 0 to start at the beginning.forwardDigit - the digit for fast forward.rewindDigit - the digit for rewind.pauseDigit - the digit for pause and unpause.
AgiException
|
Asterisk-Java | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||