|
Asterisk-Java | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface AgiChannel
Provides the functionality to send AgiCommands to Asterisk while handling an AgiRequest.
This interface is supposed to be used by AgiScripts for interaction with the Asterisk server.
Method Summary | |
---|---|
void |
answer()
Answers the channel. |
void |
continueAt(java.lang.String context,
java.lang.String extension,
java.lang.String priority)
Defines the point in the dialplan where the call will continue when the AGI script returns. |
void |
controlStreamFile(java.lang.String file)
Plays the given file allowing the user to control the streaming by using "#" for forward and "*" for rewind. |
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. |
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. |
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. |
void |
databaseDel(java.lang.String family,
java.lang.String key)
Deletes an entry in the Asterisk database for a given family and key. |
void |
databaseDelTree(java.lang.String family)
Deletes a whole family of entries in the Asterisk database. |
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. |
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. |
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. |
int |
exec(java.lang.String application)
Executes the given command. |
int |
exec(java.lang.String application,
java.lang.String options)
Executes the given command. |
int |
getChannelStatus()
Returns the status of the channel. |
java.lang.String |
getData(java.lang.String file)
Plays the given file and waits for the user to enter DTMF digits until he presses '#'. |
java.lang.String |
getData(java.lang.String file,
long timeout)
Plays the given file and waits for the user to enter DTMF digits until he presses '#' or the timeout occurs. |
java.lang.String |
getData(java.lang.String file,
long 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. |
java.lang.String |
getFullVariable(java.lang.String expr)
Evaluates a channel expression for the current channel. |
java.lang.String |
getFullVariable(java.lang.String expr,
java.lang.String channel)
Evaluates a channel expression for the given channel.To extract the caller id of channel use getFullVariable("${CALLERID(name)}", "SIP/john-0085d860"); . |
AgiReply |
getLastReply()
Returns the reply received in response to the last command sent to Asterisk. |
java.lang.String |
getName()
Returns the name of the channel. |
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. |
char |
getOption(java.lang.String file,
java.lang.String escapeDigits,
long timeout)
Plays the given file, and waits for the user to press one of the given digits. |
java.lang.String |
getUniqueId()
Returns the unqiue id of the channel. |
java.lang.String |
getVariable(java.lang.String name)
Returns the value of the current channel or global variable. |
void |
hangup()
Hangs the channel up. |
void |
playMusicOnHold()
Plays music on hold from the default music on hold class. |
void |
playMusicOnHold(java.lang.String musicOnHoldClass)
Plays music on hold from the given music on hold class. |
char |
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. |
char |
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. |
void |
sayAlpha(java.lang.String text)
Says the given character string. |
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. |
void |
sayDateTime(long time)
Says the given time. |
char |
sayDateTime(long time,
java.lang.String escapeDigits)
Says the given time and allows interruption by one of the given escape digits. |
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. |
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. |
void |
sayDigits(java.lang.String digits)
Says the given digit string. |
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. |
void |
sayNumber(java.lang.String number)
Says the given number. |
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. |
void |
sayPhonetic(java.lang.String text)
Says the given character string with phonetics. |
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. |
void |
sayTime(long time)
Says the given time. |
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. |
AgiReply |
sendCommand(AgiCommand command)
Sends a command to asterisk and returns the corresponding reply. |
void |
setAutoHangup(int time)
Cause the channel to automatically hangup at the given number of seconds in the future. |
void |
setCallerId(java.lang.String callerId)
Sets the caller id on the current channel. |
void |
setContext(java.lang.String context)
Sets the context for continuation upon exiting the application. |
void |
setExtension(java.lang.String extension)
Sets the extension for continuation upon exiting the application. |
void |
setPriority(java.lang.String priority)
Sets the priority or label for continuation upon exiting the application. |
void |
setVariable(java.lang.String name,
java.lang.String value)
Sets the value of the current channel or global variable to a new value. |
void |
speechActivateGrammar(java.lang.String label)
Activates the specified grammar. |
void |
speechCreate()
Creates a speech object that uses the default speech engine. |
void |
speechCreate(java.lang.String engine)
Creates a speech object that uses the given speech engine. |
void |
speechDeactivateGrammar(java.lang.String label)
Deactivates the specified grammar. |
void |
speechDestroy()
Destroys the current speech object. |
void |
speechLoadGrammar(java.lang.String label,
java.lang.String path)
Loads the specified grammar. |
SpeechRecognitionResult |
speechRecognize(java.lang.String prompt,
int timeout)
Plays the given prompt while listening for speech and DTMF. |
SpeechRecognitionResult |
speechRecognize(java.lang.String prompt,
int timeout,
int offset)
Plays the given prompt while listening for speech and DTMF. |
void |
speechSet(java.lang.String name,
java.lang.String value)
Sets the speech engine setting indicated by name to the given value. |
void |
speechUnloadGrammar(java.lang.String label)
Unloads the specified grammar. |
void |
stopMusicOnHold()
Stops playing music on hold. |
void |
streamFile(java.lang.String file)
Plays the given file. |
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. |
char |
streamFile(java.lang.String file,
java.lang.String escapeDigits,
int offset)
Plays the given file starting at the specified offset and allows the user to escape by pressing one of the given digit. |
void |
verbose(java.lang.String message,
int level)
Sends a message to the Asterisk console via the verbose message system. |
char |
waitForDigit(int timeout)
Waits up to 'timeout' milliseconds to receive a DTMF digit. |
Method Detail |
---|
java.lang.String getName()
java.lang.String getUniqueId()
AgiReply getLastReply()
null
if none has yet been received.AgiReply sendCommand(AgiCommand command) throws AgiException
getLastReply()
.
command
- the command to send.
AgiException
- if the command can't be sent to Asterisk (for
example because the channel has been hung up)void answer() throws AgiException
AgiException
void hangup() throws AgiException
AgiException
void setAutoHangup(int time) throws AgiException
time
- the number of seconds before this channel is automatically
hung up.0 disables the autohangup feature.
AgiException
void setCallerId(java.lang.String callerId) throws AgiException
callerId
- the raw caller id to set, for example "John Doe<1234>".
AgiException
void playMusicOnHold() throws AgiException
AgiException
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
- Since:
- 0.2
void stopMusicOnHold() throws AgiException
AgiException
int getChannelStatus() throws AgiException
Return values:
AgiException
java.lang.String getData(java.lang.String file) throws AgiException
file
- the name of the file to play
AgiException
java.lang.String getData(java.lang.String file, long 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
java.lang.String getData(java.lang.String file, long 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
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
char getOption(java.lang.String file, java.lang.String escapeDigits, long 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 milliseconds to wait if none of the defined
esacpe digits was presses while streaming.
AgiException
int exec(java.lang.String application) throws AgiException
application
- the name of the application to execute, for example
"Dial".
AgiException
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".
AgiException
void setContext(java.lang.String context) throws AgiException
context
- the context for continuation upon exiting the application.
AgiException
void setExtension(java.lang.String extension) throws AgiException
extension
- the extension for continuation upon exiting the
application.
AgiException
void setPriority(java.lang.String priority) throws AgiException
priority
- the priority or label for continuation upon exiting the
application.
AgiException
void streamFile(java.lang.String file) throws AgiException
file
- name of the file to play.
AgiException
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
char streamFile(java.lang.String file, java.lang.String escapeDigits, int offset) throws AgiException
file
- name of the file to play.escapeDigits
- a String containing the DTMF digits that allow the
user to escape.offset
- the offset samples to skip before streaming.
AgiException
void sayDigits(java.lang.String digits) throws AgiException
digits
- the digit string to say.
AgiException
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
void sayNumber(java.lang.String number) throws AgiException
number
- the number to say.
AgiException
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
void sayPhonetic(java.lang.String text) throws AgiException
text
- the text to say.
AgiException
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
void sayAlpha(java.lang.String text) throws AgiException
text
- the text to say.
AgiException
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
void sayTime(long time) throws AgiException
time
- the time to say in seconds since 00:00:00 on January 1, 1970.
AgiException
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
java.lang.String getVariable(java.lang.String name) throws AgiException
Supports functions and builtin variables. To retrieve
the caller id you can use
Does not support expression parsing, use
getVariable("CALLERID(name)");
getFullVariable(String)
in those cases.
name
- the name of the variable (or function call) to retrieve.
null
if not
set.
AgiException
void setVariable(java.lang.String name, java.lang.String value) throws AgiException
Supports functions and builtin variables. To set the caller id
you can use setVariable("CALLERID(name)", "John Doe");
name
- the name of the variable (or function call) to set.value
- the new value to set.
AgiException
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
java.lang.String getFullVariable(java.lang.String expr) throws AgiException
getFullVariable("${CALLERID(name)}");
.Available since Asterisk 1.2.
expr
- the expression to evaluate.
null
if not
set.
AgiException
getVariable(String)
java.lang.String getFullVariable(java.lang.String expr, java.lang.String channel) throws AgiException
getFullVariable("${CALLERID(name)}", "SIP/john-0085d860");
.Available since Asterisk 1.2.
expr
- the the expression to evaluate.channel
- the name of the channel.
null
if not
set.
AgiException
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
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
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
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
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
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
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
void databaseDelTree(java.lang.String family) throws AgiException
family
- the family to delete.
AgiException
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
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
char 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
char 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
void controlStreamFile(java.lang.String file) throws AgiException
file
- the name of the file to stream, must not include extension.
AgiException
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
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
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
void speechCreate() throws AgiException
AgiSpeechException
- if the speech object cannot be created.
AgiException
speechDestroy()
void speechCreate(java.lang.String engine) throws AgiException
engine
- the name of the speech engine. For example "lumenvox".
AgiSpeechException
- if the speech object cannot be created.
AgiException
speechDestroy()
void speechSet(java.lang.String name, java.lang.String value) throws AgiException
name
- the name of the setting to set.value
- the value to set.
AgiSpeechException
- if the setting cannot be set.
AgiException
void speechDestroy() throws AgiException
AgiSpeechException
- if the speech engine cannot be destroyed.
AgiException
speechCreate(String)
void speechLoadGrammar(java.lang.String label, java.lang.String path) throws AgiException
speechActivateGrammar(String)
under the given name. Eplicitly loading a grammer is only required if the grammer has not been defined in the
speech engine configuration, e.g. the [grammars]
section of lumenvox.conf
.
label
- the name of the grammar, used for subsequent calls to speechActivateGrammar(String)
,
speechDeactivateGrammar(String)
and speechUnloadGrammar(String)
.path
- the path to the grammar to load.
AgiSpeechException
- if the grammar cannot be loaded.
AgiException
speechUnloadGrammar(String)
,
speechActivateGrammar(String)
void speechUnloadGrammar(java.lang.String label) throws AgiException
label
- the name of the grammar to unload.
AgiSpeechException
- if the grammar cannot be unloaded.
AgiException
speechLoadGrammar(String, String)
void speechActivateGrammar(java.lang.String label) throws AgiException
label
- the name of the grammar to activate.
AgiSpeechException
- if the grammar cannot be activated.
AgiException
speechDeactivateGrammar(String)
,
speechLoadGrammar(String, String)
void speechDeactivateGrammar(java.lang.String label) throws AgiException
label
- the name to the grammar to deactivate.
AgiSpeechException
- if the grammar cannot be deactivated.
AgiException
speechActivateGrammar(String)
SpeechRecognitionResult speechRecognize(java.lang.String prompt, int timeout) throws AgiException
prompt
- the name of the file to stream, must not include extension.timeout
- the timeout in milliseconds to wait for user input.0 means standard timeout value, -1 means "ludicrous time" (essentially never times out).
AgiException
SpeechRecognitionResult speechRecognize(java.lang.String prompt, int timeout, int offset) throws AgiException, AgiSpeechException
prompt
- the name of the file to stream, must not include extension.timeout
- the timeout in milliseconds to wait for user input.0 means standard timeout value, -1 means "ludicrous time" (essentially never times out).
offset
- the offset samples to skip before streaming, use 0 to start at the beginning.
AgiException
AgiSpeechException
void continueAt(java.lang.String context, java.lang.String extension, java.lang.String priority) throws AgiException
This is a shortcut for calling setContext(String)
, setExtension(String)
and setPriority(String)
in series.
context
- the context for continuation upon exiting the application.extension
- the extension for continuation upon exiting the
application.priority
- the priority or label for continuation upon exiting the
application.
AgiException
setContext(String)
,
setExtension(String)
,
setPriority(String)
|
Asterisk-Java | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |