1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.xnap.chat;
21
22 import java.util.EventObject;
23
24 import org.xnap.peer.Peer;
25
26 /***
27 * An event that characterizes a change in a {@link Channel} object.
28 */
29 public class ChannelEvent extends EventObject {
30
31
32
33 public static final int MESSAGE_RECEIVED = 1;
34 public static final int PEER_ADDED = 2;
35 public static final int PEER_REMOVED = 3;
36 public static final int TOPIC_CHANGED = 4;
37 public static final int PEER_CHANGED = 5;
38 public static final int CHANNEL_JOINED = 6;
39 public static final int CHANNEL_PARTED = 7;
40
41 public static final int MESSAGE_TYPE_MESSAGE = 1;
42 public static final int MESSAGE_TYPE_INFO = 2;
43 public static final int MESSAGE_TYPE_ERROR = 3;
44 public static final int MESSAGE_TYPE_ACTION_MESSAGE = 4;
45
46
47
48 private int id;
49 private String message;
50 private int messageType;
51 private Peer peer;
52 private String topic;
53
54
55
56 public ChannelEvent(Object source, Peer peer, String message,
57 int messageType)
58 {
59 super(source);
60
61 this.id = MESSAGE_RECEIVED;
62 this.peer = peer;
63 this.message = message;
64 this.messageType = messageType;
65 }
66
67 public ChannelEvent(Object source, int id, Peer peer)
68 {
69 super(source);
70
71 this.id = id;
72 this.peer = peer;
73 }
74
75 public ChannelEvent(Object source, String topic)
76 {
77 super(source);
78
79 this.id = TOPIC_CHANGED;
80 this.topic = topic;
81 }
82
83 public ChannelEvent(Object source, int id)
84 {
85 super(source);
86
87 this.id = id;
88 }
89
90
91
92 public int getID()
93 {
94 return id;
95 }
96
97 public String getMessage()
98 {
99 return message;
100 }
101
102 public int getMessageType()
103 {
104 return messageType;
105 }
106
107 public Peer getPeer()
108 {
109 return peer;
110 }
111
112 public String getTopic()
113 {
114 return topic;
115 }
116
117 }