Asterisk-Java

org.asteriskjava.fastagi.command
Class GetOptionCommand

java.lang.Object
  extended by org.asteriskjava.fastagi.command.AbstractAgiCommand
      extended by org.asteriskjava.fastagi.command.GetOptionCommand
All Implemented Interfaces:
java.io.Serializable, AgiCommand

public class GetOptionCommand
extends AbstractAgiCommand

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 this command waits for the specified timeout still waiting for the user to press a digit. Streaming always begins at the beginning.

Returns 0 if no digit being pressed, or the ASCII numerical value of the digit if one was pressed, or -1 on error or if the channel was disconnected.

Remember, the file extension must not be included in the filename.

Version:
$Id: GetOptionCommand.java 1246 2009-03-10 04:00:32Z srt $
Author:
srt
See Also:
StreamFileCommand, Serialized Form

Constructor Summary
GetOptionCommand(java.lang.String file, java.lang.String escapeDigits)
          Creates a new GetOptionCommand with a default timeout of 5 seconds.
GetOptionCommand(java.lang.String file, java.lang.String escapeDigits, long timeout)
          Creates a new GetOptionCommand with the given timeout.
 
Method Summary
 java.lang.String buildCommand()
          Returns a string suitable to be sent to asterisk.
 java.lang.String getEscapeDigits()
          Returns the digits that the user is expected to press.
 java.lang.String getFile()
          Returns the name of the file to stream.
 long getTimeout()
          Returns the timeout to wait if none of the defined esacpe digits was presses while streaming.
 void setEscapeDigits(java.lang.String escapeDigits)
          Sets the digits that the user is expected to press.
 void setFile(java.lang.String file)
          Sets the name of the file to stream.
 void setTimeout(long timeout)
          Sets the timeout to wait if none of the defined esacpe digits was presses while streaming.
 
Methods inherited from class org.asteriskjava.fastagi.command.AbstractAgiCommand
escapeAndQuote, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

GetOptionCommand

public GetOptionCommand(java.lang.String file,
                        java.lang.String escapeDigits)
Creates a new GetOptionCommand with a default timeout of 5 seconds.

Parameters:
file - the name of the file to stream, must not include extension.
escapeDigits - contains the digits that the user is expected to press.

GetOptionCommand

public GetOptionCommand(java.lang.String file,
                        java.lang.String escapeDigits,
                        long timeout)
Creates a new GetOptionCommand with the given timeout.

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 milliseconds to wait if none of the defined esacpe digits was presses while streaming.
Method Detail

getFile

public java.lang.String getFile()
Returns the name of the file to stream.

Returns:
the name of the file to stream.

setFile

public void setFile(java.lang.String file)
Sets the name of the file to stream.

Parameters:
file - the name of the file to stream, must not include extension.

getEscapeDigits

public java.lang.String getEscapeDigits()
Returns the digits that the user is expected to press.

Returns:
the digits that the user is expected to press.

setEscapeDigits

public void setEscapeDigits(java.lang.String escapeDigits)
Sets the digits that the user is expected to press.

Parameters:
escapeDigits - the digits that the user is expected to press.

getTimeout

public long getTimeout()
Returns the timeout to wait if none of the defined esacpe digits was presses while streaming.

Returns:
the timeout in milliseconds.

setTimeout

public void setTimeout(long timeout)
Sets the timeout to wait if none of the defined esacpe digits was presses while streaming.

Parameters:
timeout - the timeout in milliks,seconds.

buildCommand

public java.lang.String buildCommand()
Description copied from interface: AgiCommand
Returns a string suitable to be sent to asterisk.

Specified by:
buildCommand in interface AgiCommand
Specified by:
buildCommand in class AbstractAgiCommand
Returns:
a string suitable to be sent to asterisk.

Asterisk-Java

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