using System; namespace AsterNET.FastAGI.Command { /// /// 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. ///
/// public class GetOptionCommand : AGICommand { /// The name of the file to stream. private string file; /// When one of these digits is pressed while streaming the command returns. private string escapeDigits; /// The timeout in seconds. private int timeout; /// /// Get/Set the name of the file to stream. /// public string File { get { return file; } set { this.file = value; } } /// /// Get/Set the digits that the user is expected to press. /// public string EscapeDigits { get { return escapeDigits; } set { this.escapeDigits = value; } } /// /// Get/Set the timeout to wait if none of the defined esacpe digits was presses while streaming. /// public int Timeout { get { return timeout; } set { this.timeout = value; } } /// /// Creates a new GetOptionCommand with a default timeout of 5 seconds. /// /// the name of the file to stream, must not include extension. /// contains the digits that the user is expected to press. public GetOptionCommand(string file, string escapeDigits) { this.file = file; this.escapeDigits = escapeDigits; this.timeout = - 1; } /// /// Creates a new GetOptionCommand with the given timeout. /// /// the name of the file to stream, must not include extension. /// contains the digits that the user is expected to press. /// the timeout in seconds to wait if none of the defined esacpe digits was presses while streaming. public GetOptionCommand(string file, string escapeDigits, int timeout) { this.file = file; this.escapeDigits = escapeDigits; this.timeout = timeout; } public override string BuildCommand() { return "GET OPTION " + EscapeAndQuote(file) + " " + EscapeAndQuote(escapeDigits) + (timeout < 0?"":" " + timeout); } } }