1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package net.sf.asterisk.fastagi.command;
18
19 /***
20 * Waits up to 'timeout' milliseconds for channel to receive a DTMF digit.<br>
21 * Returns -1 on channel failure, 0 if no digit is received in the timeout, or
22 * the numerical value of the ascii of the digit if one is received. Use -1 for
23 * the timeout value if you desire the call to block indefinitely.
24 *
25 * @author srt
26 * @version $Id: WaitForDigitCommand.java,v 1.3 2005/11/17 17:41:35 srt Exp $
27 */
28 public class WaitForDigitCommand extends AGICommand
29 {
30 /***
31 * Serial version identifier.
32 */
33 private static final long serialVersionUID = 3257562923458443314L;
34
35 /***
36 * The milliseconds to wait for the channel to receive a DTMF digit.
37 */
38 private long timeout;
39
40 /***
41 * Creates a new WaitForDigitCommand with a default timeout of -1 which
42 * blocks the channel indefinitely.
43 */
44 public WaitForDigitCommand()
45 {
46 this.timeout = -1;
47 }
48
49 /***
50 * Creates a new WaitForDigitCommand.
51 *
52 * @param timeout the milliseconds to wait for the channel to receive a DTMF
53 * digit.
54 */
55 public WaitForDigitCommand(long timeout)
56 {
57 this.timeout = timeout;
58 }
59
60 /***
61 * Returns the milliseconds to wait for the channel to receive a DTMF digit.
62 *
63 * @return the milliseconds to wait for the channel to receive a DTMF digit.
64 */
65 public long getTimeout()
66 {
67 return timeout;
68 }
69
70 /***
71 * Sets the milliseconds to wait for the channel to receive a DTMF digit.
72 *
73 * @param timeout the milliseconds to wait for the channel to receive a DTMF
74 * digit.
75 */
76 public void setTimeout(long timeout)
77 {
78 this.timeout = timeout;
79 }
80
81 public String buildCommand()
82 {
83 return "WAIT FOR DIGIT " + timeout;
84 }
85 }