1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package net.sf.asterisk.manager.event;
18
19 /***
20 * Abstract base class for user events.<br>
21 * You can send arbitrary user events via the UserEvent application provided with asterisk. A user
22 * event by default has the attributes channel and uniqueId but you can add custom attributes by
23 * specifying an event body.<br>
24 * To add your own user events you must subclass this class and name it corresponding to your event.
25 * If you plan to send an event by <code>UserEvent(VIPCall)</code> you will create a new class
26 * called VIPCallEvent that extends UserEvent. The name of this class is important: Just use the
27 * name of the event you will send (VIPCall in this example) and append "Event".<br>
28 * To pass additional data create appropriate attributes with getter and setter methods in your
29 * new class.<br>
30 * Example:
31 * <pre>
32 * public class VIPCallEvent extends UserEvent
33 * {
34 * private String firstName;
35 *
36 * public VIPCallEvent(Object source)
37 * {
38 * super(source);
39 * }
40 *
41 * public String getFirstName()
42 * {
43 * return firstName;
44 * }
45 *
46 * public void setFirstName(String firstName)
47 * {
48 * this.firstName = firstName;
49 * }
50 * }
51 * </pre>
52 * To send this event use <code>UserEvent(VIPCall|firstName: Jon)</code> in your dialplan.<br>
53 * The UserEvent is implemented in <code>apps/app_userevent.c</code>.<br>
54 * Note that you must register your UserEvent with the ManagerConnection you are using in order
55 * to be recognized.
56 *
57 * @see net.sf.asterisk.manager.ManagerConnection#registerUserEventClass(Class)
58 *
59 * @author srt
60 * @version $Id: UserEvent.java,v 1.2 2005/03/15 16:29:02 srt Exp $
61 */
62 public abstract class UserEvent extends ManagerEvent
63 {
64 /***
65 * Serial version identifier
66 */
67 private static final long serialVersionUID = 3256725065466000695L;
68
69 /***
70 * The name of the channel.
71 */
72 private String channel;
73
74 /***
75 * The unique id of the channel.
76 */
77 private String uniqueId;
78
79 public UserEvent(Object source)
80 {
81 super(source);
82 }
83
84 /***
85 * Returns the name of the channel this event occured in.
86 *
87 * @return the name of the channel this event occured in.
88 */
89 public String getChannel()
90 {
91 return channel;
92 }
93
94 /***
95 * Sets the name of the channel this event occured in.
96 *
97 * @param channel the name of the channel this event occured in.
98 */
99 public void setChannel(String channel)
100 {
101 this.channel = channel;
102 }
103
104 /***
105 * Returns the unqiue id of the channel this event occured in.
106 *
107 * @return the unqiue id of the channel this event occured in.
108 */
109 public String getUniqueId()
110 {
111 return uniqueId;
112 }
113
114 /***
115 * Sets the unqiue id of the channel this event occured in.
116 *
117 * @param uniqueId the unqiue id of the channel this event occured in.
118 */
119 public void setUniqueId(String uniqueId)
120 {
121 this.uniqueId = uniqueId;
122 }
123 }