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 * Receives a character of text on a channel.<br>
21 * Specify timeout to be the maximum time to wait for input in milliseconds, or
22 * 0 for infinite.<br>
23 * Most channels do not support the reception of text.<br>
24 * Returns the decimal value of the character if one is received, or 0 if the
25 * channel does not support text reception. Returns -1 only on error/hangup.
26 *
27 * @author srt
28 * @version $Id: ReceiveCharCommand.java,v 1.2 2005/03/08 16:48:34 srt Exp $
29 */
30 public class ReceiveCharCommand extends AGICommand
31 {
32 /***
33 * Serial version identifier.
34 */
35 private static final long serialVersionUID = 3256719598056387384L;
36
37 /***
38 * The milliseconds to wait for the channel to receive a character.
39 */
40 private int timeout;
41
42 /***
43 * Creates a new ReceiveCharCommand with a default timeout of 0 meaning to
44 * wait for ever.
45 */
46 public ReceiveCharCommand()
47 {
48 this.timeout = 0;
49 }
50
51 /***
52 * Creates a new ReceiveCharCommand.
53 *
54 * @param timeout the milliseconds to wait for the channel to receive a
55 * character.
56 */
57 public ReceiveCharCommand(int timeout)
58 {
59 this.timeout = timeout;
60 }
61
62 /***
63 * Returns the milliseconds to wait for the channel to receive a character.
64 *
65 * @return the milliseconds to wait for the channel to receive a character.
66 */
67 public int getTimeout()
68 {
69 return timeout;
70 }
71
72 /***
73 * Sets the milliseconds to wait for the channel to receive a character.
74 *
75 * @param timeout the milliseconds to wait for the channel to receive a
76 * character.
77 */
78 public void setTimeout(int timeout)
79 {
80 this.timeout = timeout;
81 }
82
83 public String buildCommand()
84 {
85 return "RECEIVE CHAR " + timeout;
86 }
87 }