1
package networking;
2![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
3
import java.io.*;
4![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
5![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
/** *//**
6
* Class that will send the send file request
7
* @author
8
* @version 1.0
9
*/
10
public class RequestFrame implements Serializable
11![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
{
12![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/** *//**
13
* Attributes
14
*/
15
private static final long serialVersionUID = 1L;
16
private String sender;
17
private String receiver;
18
private long senderKey;
19
private long fileSize;
20
private double totalSections;
21
private double packageSize;
22
private String fileName;
23![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/** *//**
24
* Constructor
25
*/
26
public RequestFrame(String sender, String receiver, long senderKey, long fileSize, double totalSections, double packageSize,String fileName)
27![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
28
this.sender = sender;
29
this.receiver = receiver;
30
this.senderKey = senderKey;
31
this.fileSize = fileSize;
32
this.totalSections = totalSections;
33
this.packageSize = packageSize;
34
this.fileName=fileName;
35
}
36![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/** *//**
37
* Class attribute getter
38
* @return the fileSize
39
*/
40
public long getFileSize()
41![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
42
return this.fileSize;
43
}
44![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/** *//**
45
* Class attribute setter
46
* @param fileSize the fileSize to set
47
*/
48
public void setFileSize(long fileSize)
49![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
50
this.fileSize = fileSize;
51
}
52![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/** *//**
53
* Class attribute getter
54
* @return the packageSize
55
*/
56
public double getPackageSize()
57![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
58
return this.packageSize;
59
}
60![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/** *//**
61
* Class attribute setter
62
* @param packageSize the packageSize to set
63
*/
64
public void setPackageSize(double packageSize)
65![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
66
this.packageSize = packageSize;
67
}
68![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/** *//**
69
* Class attribute getter
70
* @return the receiver
71
*/
72
public String getReceiver()
73![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
74
return this.receiver;
75
}
76![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/** *//**
77
* Class attribute setter
78
* @param receiver the receiver to set
79
*/
80
public void setReceiver(String receiver)
81![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
82
this.receiver = receiver;
83
}
84![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/** *//**
85
* Class attribute getter
86
* @return the sender
87
*/
88
public String getSender()
89![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
90
return this.sender;
91
}
92![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/** *//**
93
* Class attribute setter
94
* @param sender the sender to set
95
*/
96
public void setSender(String sender)
97![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
98
this.sender = sender;
99
}
100![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/** *//**
101
* Class attribute getter
102
* @return the senderKey
103
*/
104
public long getSenderKey()
105![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
106
return this.senderKey;
107
}
108![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/** *//**
109
* Class attribute setter
110
* @param senderKey the senderKey to set
111
*/
112
public void setSenderKey(long senderKey)
113![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
114
this.senderKey = senderKey;
115
}
116![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/** *//**
117
* Class attribute getter
118
* @return the totalSections
119
*/
120
public double getTotalSections()
121![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
122
return this.totalSections;
123
}
124![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/** *//**
125
* Class attribute setter
126
* @param totalSections the totalSections to set
127
*/
128
public void setTotalSections(double totalSections)
129![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
130
this.totalSections = totalSections;
131
}
132![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/** *//**
133
* Class attribute getter
134
* @return the fileName
135
*/
136
public String getFileName()
137![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
138
return this.fileName;
139
}
140![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/** *//**
141
* Class attribute setter
142
* @param fileName the fileName to set
143
*/
144
public void setFileName(String fileName)
145![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
146
this.fileName = fileName;
147
}
148
}
149![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
1
package networking;
2![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
3
import java.io.*;
4
import java.net.*;
5![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
6![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
/** *//**
7
* class that has the run method that the thread will use
8
*
9
* @author
10
* @version 1.0
11
*/
12
public class ServerThreadHandler implements Runnable
13![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
{
14![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/** *//**
15
* Attributes
16
*/
17
private Socket socket;
18
private ServerGUI serverGUI;
19
private static final int TIMEOUT_LENGTH = 1000 * 60 * 60*5;// max timeout
20
21
// number,60
22
// minutes
23![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/** *//**
24
* Constructor
25
*/
26
public ServerThreadHandler(Socket socket, ServerGUI serverGUI)
27![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
28
this.socket = socket;
29
try
30![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
31
this.socket.setSoTimeout(TIMEOUT_LENGTH);
32
}
33
catch(SocketException se)
34![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
35
}
36
this.serverGUI = serverGUI;
37
}
38
39![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//*
40
* (non-Javadoc)
41
*
42
* @see java.lang.Runnable#run()
43
*/
44
public void run()
45![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
46
try
47![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
48
ObjectInputStream ois = new ObjectInputStream(socket
49
.getInputStream());
50
ObjectOutputStream oos = new ObjectOutputStream(socket
51
.getOutputStream());
52
try
53![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
54
while(true)
55![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
56
DataFrame df = (DataFrame)ois.readObject();
57
if(df.getType().equals("Login"))
58![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
59
String name = (String)df.getObject();
60
if(Secretary.getSecretary().isExist(name))
61![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
62
oos.reset();
63
oos.writeObject(new DataFrame("Error",
64
"Name already exists"));// name exists
65
oos.flush();
66
}
67
else if(Coordinator.getCoordinator().findCaller(socket) != null)
68![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
69
oos.reset();
70
oos.writeObject(new DataFrame("Error",
71
"IP and port already exist"));// ip and
72
// port
73
// exist
74
oos.flush();
75
}
76
else
77![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
78
Secretary.getSecretary().addRecord(socket, name);
79
Coordinator.getCoordinator().notifyOnline(
80
new Caller(socket, oos));
81
this.serverGUI.addText(name + " logined");// login
82
// request
83
}
84
continue;
85
}
86
if(Coordinator.getCoordinator().findCaller(socket) == null)
87![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
88
oos.reset();
89
oos.writeObject(new DataFrame("Error",
90
"Must login first"));// login validation
91
oos.flush();
92
}
93
else if(df.getType().equals("Room"))
94![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
95
String nextRoom = (String)df.getObject();
96
Chatter chatter = Secretary.getSecretary().findChatter(
97
socket);
98
String previousRoom = chatter.getRoom();
99
chatter.setRoom(nextRoom);
100
Coordinator.getCoordinator().updateRooms(previousRoom,
101
nextRoom);
102
this.serverGUI.addText(chatter.getName()
103
+ " changed room to " + chatter.getRoom());// change
104
// room
105
// request
106
}
107
else if(df.getType().equals("Public"))
108![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
109
String message = (String)df.getObject();
110
Chatter chatter = Secretary.getSecretary().findChatter(
111
socket);
112
Coordinator.getCoordinator().sendPublicMessage(chatter,
113
message);
114
this.serverGUI.addText(chatter.getName()
115
+ " sent public message:\n" + message);// send
116
// public
117
// message
118
// request
119
}
120
else if(df.getType().startsWith("Private"))
121![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
122
Chatter sender = Secretary.getSecretary().findChatter(
123
socket);
124
String name = df.getType().replaceFirst("Private", "");
125
Chatter receiver = Secretary.getSecretary()
126
.findChatter(name);
127
String message = (String)df.getObject();
128
Coordinator.getCoordinator().sendPrivateMessage(
129
message, receiver, sender);
130
this.serverGUI.addText(sender.getName()
131
+ " sent private message" + message + " to "
132
+ receiver.getName() + ":\n");// send private
133
// message
134
// request
135
}
136
else if(df.getType().equals("Logout"))
137![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
138
synchronized(Coordinator.getCoordinator())
139![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
140
Chatter chatter = Secretary.getSecretary()
141
.findChatter(socket);
142
Secretary.getSecretary().deleteRecord(socket);
143
Coordinator.getCoordinator().notifyOffline(
144
Coordinator.getCoordinator().findCaller(
145
socket), chatter.getRoom());
146
this.serverGUI.addText(chatter.getName()
147
+ " loged out");// logout request
148
}
149
}
150
else if(df.getType().equals("SendFileRequest"))
151![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
152
RequestFrame rf = (RequestFrame)df.getObject();
153
Chatter sender = Secretary.getSecretary().findChatter(
154
rf.getSender());
155
Chatter receiver = Secretary.getSecretary()
156
.findChatter(rf.getReceiver());
157
Coordinator.getCoordinator().sendPrivateInformation(rf,
158
"ReceiveFileRequest", "SendFileError",
159
receiver, sender);
160
this.serverGUI.addText(sender.getName()
161
+ " sent send file request to "
162
+ receiver.getName() + ":\n");
163
}
164
else if(df.getType().equals("SendFileAcknowledgement"))
165![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
166
AcknowledgementFrame af = (AcknowledgementFrame)df
167
.getObject();
168
Chatter sender = Secretary.getSecretary().findChatter(
169
af.getSender());
170
Chatter receiver = Secretary.getSecretary()
171
.findChatter(af.getReceiver());
172
Coordinator.getCoordinator().sendPrivateInformation(af,
173
"ReceiveFileAcknowledgement",
174
"ReceiveFileError", sender, receiver);
175
this.serverGUI.addText(receiver.getName()
176
+ " sent send file acknowledegment to "
177
+ sender.getName() + ":\n");
178
}
179
else if(df.getType().equals("SendFileSection"))
180![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
181
FileFrame ff = (FileFrame)df.getObject();
182
Chatter sender = Secretary.getSecretary().findChatter(
183
ff.getSender());
184
Chatter receiver = Secretary.getSecretary()
185
.findChatter(ff.getReceiver());
186
Coordinator.getCoordinator().sendPrivateInformation(ff,
187
"ReceiveFileSection", "SendFileSectionError",
188
receiver, sender);
189
// this.serverGUI.addText(sender.getName()
190
// + " sent send file section to "
191
// + receiver.getName() + ":\n");
192
}
193
else if(df.getType().equals("IGotTheRequest"))
194![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
195
NotifyFrame nf=(NotifyFrame)df.getObject();
196
Chatter sender = Secretary.getSecretary().findChatter(
197
nf.getSender());
198
Chatter receiver = Secretary.getSecretary()
199
.findChatter(nf.getReceiver());
200
Coordinator.getCoordinator().sendPrivateInformation(nf,
201
"SheGotTheRequest",
202
"SomethingWrong", sender, receiver);
203
this.serverGUI.addText(receiver.getName()
204
+ " send receive notification of request to "
205
+ sender.getName() + ":\n");
206
}
207
else if(df.getType().equals("CancelFileSendFromSender"))
208![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
209
CancelFrame cf = (CancelFrame)df.getObject();
210
Chatter sender = Secretary.getSecretary().findChatter(
211
cf.getSender());
212
Chatter receiver = Secretary.getSecretary()
213
.findChatter(cf.getReceiver());
214
Coordinator.getCoordinator().sendPrivateInformation(cf,
215
"ReceiveCancelFileSendFromSender",
216
"CancelFileSendFromSenderError", receiver,
217
sender);
218
this.serverGUI.addText(sender.getName()
219
+ " send cancel file send to "
220
+ receiver.getName() + ":\n");
221
}
222
else if(df.getType().equals("CancelFileSendFromReceiver"))
223![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
224
CancelFrame cf = (CancelFrame)df.getObject();
225
Chatter sender = Secretary.getSecretary().findChatter(
226
cf.getSender());
227
Chatter receiver = Secretary.getSecretary()
228
.findChatter(cf.getReceiver());
229
Coordinator.getCoordinator().sendPrivateInformation(cf,
230
"ReceiveCancelFileSendFromReceiver",
231
"CancelFileSendFromReceiverError", sender,
232
receiver);
233
this.serverGUI.addText(receiver.getName()
234
+ " send cancel file send to "
235
+ sender.getName() + ":\n");
236
}
237
else
238![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
239
oos.reset();
240
oos.writeObject(new DataFrame("Error", df.getType()));
241
oos.flush();
242
}
243
}
244
}
245
catch(ClassNotFoundException e)
246![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
247
if(Coordinator.getCoordinator().findCaller(socket) != null)
248![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
249
synchronized(Coordinator.getCoordinator())
250![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
251
Chatter chatter = Secretary.getSecretary().findChatter(
252
socket);
253
Secretary.getSecretary().deleteRecord(socket);
254
Coordinator.getCoordinator()
255
.notifyOffline(
256
Coordinator.getCoordinator()
257
.findCaller(socket),
258
chatter.getRoom());
259
this.serverGUI
260
.addText(chatter.getName() + " loged out");// exception
261
// that
262
// will
263
// notify
264
// the
265
// other
266
// chatters
267
}
268
}
269
socket.close();
270
}
271
catch(InterruptedIOException iioe)
272![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
273
if(Coordinator.getCoordinator().findCaller(socket) != null)
274![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
275
synchronized(Coordinator.getCoordinator())
276![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
277
Chatter chatter = Secretary.getSecretary().findChatter(
278
socket);
279
Secretary.getSecretary().deleteRecord(socket);
280
Coordinator.getCoordinator()
281
.notifyOffline(
282
Coordinator.getCoordinator()
283
.findCaller(socket),
284
chatter.getRoom());
285
this.serverGUI
286
.addText(chatter.getName() + " loged out");// exception
287
// that
288
// will
289
// notify
290
// the
291
// other
292
// users
293
}
294
}
295
socket.close();
296
}
297
catch(IOException ioe)
298![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
299
if(Coordinator.getCoordinator().findCaller(socket) != null)
300![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
301
synchronized(Coordinator.getCoordinator())
302![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
303
Chatter chatter = Secretary.getSecretary().findChatter(
304
socket);
305
Secretary.getSecretary().deleteRecord(socket);
306
Coordinator.getCoordinator()
307
.notifyOffline(
308
Coordinator.getCoordinator()
309
.findCaller(socket),
310
chatter.getRoom());
311
this.serverGUI
312
.addText(chatter.getName() + " loged out");// exception
313
}
314
}
315
socket.close();
316
}
317
}
318
catch(IOException ioe)
319![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
320
}
321
}
322
}
323![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
1
package networking;
2![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
3
import java.awt.*;
4
import java.awt.event.*;
5
import javax.swing.*;
6![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
7![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
/** *//**
8
* server gui class that will display the updated information
9
*
10
* @author
11
* @version 1.0
12
*/
13
public class ServerGUI extends JFrame
14![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
{
15![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/** *//**
16
* Attributes
17
*/
18
private static final long serialVersionUID = 1L;
19
private JPanel jContentPane = null;
20
private JDesktopPane jDesktopPane = null;
21
private JScrollPane jScrollPane = null;
22
private JTextArea jTextArea = null;
23
24![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/** *//**
25
* This is the default constructor
26
*/
27
public ServerGUI()
28![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
29
super();
30
initialize();
31
this.addWindowListener(new WindowAdapter()
32![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
33
public void windowClosing(WindowEvent e)
34![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
35
System.exit(0);// close the application,it will cause the
36
// socket to be closed
37
}
38
});
39
}
40
41![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/** *//**
42
* This method initializes this
43
*
44
* @return void
45
*/
46
private void initialize()
47![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
48
this.setSize(579, 356);
49
this.setContentPane(getJContentPane());
50
this.setTitle("JFrame");
51
}
52
53![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/** *//**
54
* This method initializes jContentPane
55
*
56
* @return javax.swing.JPanel
57
*/
58
private JPanel getJContentPane()
59![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
60
if(jContentPane == null)
61![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
62
jContentPane = new JPanel();
63
jContentPane.setLayout(new BorderLayout());
64
jContentPane.add(getJDesktopPane(), BorderLayout.CENTER);
65
}
66
return jContentPane;
67
}
68
69![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/** *//**
70
* This method initializes jDesktopPane
71
*
72
* @return javax.swing.JDesktopPane
73
*/
74
private JDesktopPane getJDesktopPane()
75![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
76
if(jDesktopPane == null)
77![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
78
jDesktopPane = new JDesktopPane();
79
jDesktopPane.add(getJScrollPane(), null);
80
}
81
return jDesktopPane;
82
}
83
84![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/** *//**
85
* This method initializes jScrollPane
86
*
87
* @return javax.swing.JScrollPane
88
*/
89
private JScrollPane getJScrollPane()
90![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
91
if(jScrollPane == null)
92![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
93
jScrollPane = new JScrollPane();
94
jScrollPane.setBounds(new Rectangle(96, 14, 391, 266));
95
jScrollPane.setViewportView(getJTextArea());
96
}
97
return jScrollPane;
98
}
99
100![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/** *//**
101
* This method initializes jTextArea
102
*
103
* @return javax.swing.JTextArea
104
*/
105
private JTextArea getJTextArea()
106![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
107
if(jTextArea == null)
108![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
109
jTextArea = new JTextArea();
110
}
111
return jTextArea;
112
}
113
114![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/** *//**
115
* method to add the text to the text field in the gui
116
*
117
* @param text
118
*/
119
public void addText(String text)
120![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
121
if(this.jTextArea.getText().length() > 20000)
122![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
123
this.jTextArea.setText("");
124
}
125
else
126![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
127
if(this.jTextArea.getText().equals(""))
128![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
129
this.jTextArea.setText(text);
130
}
131
else
132![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
133
this.jTextArea.setText(this.jTextArea.getText() + "\n" + text);
134
}
135
}
136
}
137
}
138![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
1
package networking;
2![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
3
import java.io.*;
4
import java.net.*;
5![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
6![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
/** *//**
7
* method that will start the server,and begin to listen to the connection
8
* requests and create new threads to deal with those requests
9
*
10
* @author
11
* @version 1.0
12
*/
13
public class Server
14![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
{
15![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/** *//**
16
* Attributes
17
*/
18
private ServerSocket ss;
19
private static final int BIND_PORT = 2008;
20
private static final int MAX_CONNECTIONS = 1000;
21
private static ThreadGroup connections = new ThreadGroup("connections");
22
private ServerGUI serverGUI;
23
24![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/** *//**
25
* Constructor
26
*/
27
public Server(ServerGUI serverGUI)
28![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
29
this.serverGUI = serverGUI;
30
}
31
32![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/** *//**
33
* method to start the server
34
*/
35
public void run()
36![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
37
try
38![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
39
ss = new ServerSocket(BIND_PORT);
40
while(true)
41![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
42
try
43![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
44
Socket socket = ss.accept();
45
if(connections.activeCount() >= MAX_CONNECTIONS)// if the
46
// server
47
// has
48
// reached
49
// the max
50
// connections,then
51
// drop the
52
// request
53![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
54
socket.close();
55
}
56
else
57![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
58
ServerThreadHandler sth = new ServerThreadHandler(
59
socket, serverGUI);
60
Thread thread = new Thread(connections, sth);
61
thread.start();// create new thread to deal with the
62
// new connection
63
}
64
}
65
catch(IOException e)
66![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
67
continue;
68
}
69
}
70
}
71
catch(IOException e)
72![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
73
}
74
}
75
76![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/** *//**
77
* main method to start the application
78
*
79
* @param args
80
*/
81
public static void main(String[] args)
82![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
83
ServerGUI serverGUI = new ServerGUI();
84
serverGUI.setVisible(true);
85
Server server = new Server(serverGUI);
86
server.run();
87
}
88
}
89![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
1
package networking;
2![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
3
import java.net.*;
4
import java.util.*;
5![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
6![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
/** */
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
![](https://www.cnblogs.com/Images/dot.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
/**
7
* class that will hold all the current connected chatter's information
8
*
9
* @author
10![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
* @version 1.0
11*/ 12publicclass Secretary
13{
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](https://www.cnblogs.com/Images/dot.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](https://www.cnblogs.com/Images/dot.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](https://www.cnblogs.com/Images/dot.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](https://www.cnblogs.com/Images/dot.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](https://www.cnblogs.com/Images/dot.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](https://www.cnblogs.com/Images/dot.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](https://www.cnblogs.com/Images/dot.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](https://www.cnblogs.com/Images/dot.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](https://www.cnblogs.com/Images/dot.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](https://www.cnblogs.com/Images/dot.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](https://www.cnblogs.com/Images/dot.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](https://www.cnblogs.com/Images/dot.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](https://www.cnblogs.com/Images/dot.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](https://www.cnblogs.com/Images/dot.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](https://www.cnblogs.com/Images/dot.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](https://www.cnblogs.com/Images/dot.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](https://www.cnblogs.com/Images/dot.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](https://www.cnblogs.com/Images/dot.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](https://www.cnblogs.com/Images/dot.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](https://www.cnblogs.com/Images/dot.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](https://www.cnblogs.com/Images/dot.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](https://www.cnblogs.com/Images/dot.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](https://www.cnblogs.com/Images/dot.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](https://www.cnblogs.com/Images/dot.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](https://www.cnblogs.com/Images/dot.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](https://www.cnblogs.com/Images/dot.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](https://www.cnblogs.com/Images/dot.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](https://www.cnblogs.com/Images/dot.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](https://www.cnblogs.com/Images/dot.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](https://www.cnblogs.com/Images/dot.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](https://www.cnblogs.com/Images/dot.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
14/** *//** 15 * Attributes
16*/ 17private ArrayList<Chatter> register;
18privatestatic Secretary secretary;
19 20/** *//** 21 * Constructor
22*/ 23private Secretary()
24{
25 register =new ArrayList<Chatter>();
26 } 27 28/** *//** 29 * singleton pattern that will only hold one instance of this class
30 *
31 * @return Secretary
32*/ 33publicstatic Secretary getSecretary()
34{
35if(secretary ==null)
36{
37 secretary =new Secretary();
38 } 39return secretary;
40 } 41 42/** *//** 43 * method that will add the record to the list
44 *
45 * @param socket
46 * @param name
47*/ 48publicvoid addRecord(Socket socket, String name)
49{
50 Chatter chatter =new Chatter(socket, name);
51synchronized(this.register)
52{
53this.register.add(chatter);
54 } 55 } 56 57/** *//** 58 * method that will delete the record in the list
59 *
60 * @param socket
61*/ 62publicvoid deleteRecord(Socket socket)
63{
64synchronized(this.register)
65{
66 Chatter targetChatter =null;
67for(Chatter chatter: this.register)
68{
69if(chatter.getIP().equals(socket.getInetAddress().toString()))
70{
71if(chatter.getPort() == socket.getPort())
72{
73 targetChatter = chatter;
74 } 75 } 76 } 77if(targetChatter !=null)
78{
79this.register.remove(targetChatter);
80 } 81 } 82 } 83 84/** *//** 85 * method that will find the chatter through his name
86 *
87 * @param name
88 * @return Chatter
89*/ 90public Chatter findChatter(String name)
91{
92synchronized(this.register)
93{
94for(Chatter chatter: this.register)
95{
96if(chatter.getName().equals(name))
97{
98return chatter;
99 }100 }101 }102returnnull;
103 }104105/** *//**106 * method that will find the chatter through his ip and port
107 *
108 * @param socket
109 * @return Chatter
110*/111public Chatter findChatter(Socket socket)
112{
113synchronized(this.register)
114{
115for(Chatter chatter: this.register)
116{
117if(chatter.getIP().equals(socket.getInetAddress().toString()))
118{
119if(chatter.getPort() == socket.getPort())
120{
121return chatter;
122 }123 }124 }125 }126returnnull;
127 }128129/** *//**130 * method that will check to see if the name has existed or not
131 *
132 * @param name
133 * @return boolean
134*/135publicboolean isExist(String name)
136{
137synchronized(this.register)
138{
139for(Chatter chatter: this.register)
140{
141if(chatter.getName().equals(name))
142{
143returntrue;
144 }145 }146 }147returnfalse;
148 }149150/** *//**151 * method that will return the list of all the chatters
152 *
153 * @return ArrayList<Chatter>
154*/155public ArrayList<Chatter> getRegister()
156{
157returnthis.register;
158 }159160/** *//**161 * method that will return the list of all the chatters in the particular
162 * room
163 *
164 * @param room
165 * @return ArrayList<Chatter>
166*/167public ArrayList<Chatter> getRegister(String room)
168{
169 ArrayList<Chatter> roomRegister =new ArrayList<Chatter>();
170synchronized(this.register)
171{
172if(room.equals("Hall"))
173{
174returnthis.register;
175 }176else177{
178for(Chatter chatter: this.register)
179{
180if(chatter.getRoom().equals(room))
181{
182 roomRegister.add(chatter);
183 }184 }185 }186 }187return roomRegister;
188 }189}190
1
package networking;
2![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
3
import java.io.*;
4![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
5![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
/** *//**
6
* @author
7
* @version 1.0
8
*/
9
public class NotifyFrame implements Serializable
10![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
{
11![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/** *//**
12
* Attributes
13
*/
14
private static final long serialVersionUID = 1L;
15
private String sender;
16
private String receiver;
17
private long senderKey;
18
private long receiverKey;
19![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/** *//**
20
* Constructor
21
*/
22
public NotifyFrame(String sender, String receiver, long senderKey,long receiverKey)
23![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
24
this.sender = sender;
25
this.receiver = receiver;
26
this.senderKey = senderKey;
27
this.receiverKey=receiverKey;
28
}
29![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/** *//**
30
* Class attribute getter
31
* @return the receiverKey
32
*/
33
public long getReceiverKey()
34![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
35
return this.receiverKey;
36
}
37![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/** *//**
38
* Class attribute setter
39
* @param receiverKey the receiverKey to set
40
*/
41
public void setReceiverKey(long receiverKey)
42![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
43
this.receiverKey = receiverKey;
44
}
45![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/** *//**
46
* Class attribute getter
47
* @return the receiver
48
*/
49
public String getReceiver()
50![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
51
return this.receiver;
52
}
53![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/** *//**
54
* Class attribute setter
55
* @param receiver the receiver to set
56
*/
57
public void setReceiver(String receiver)
58![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
59
this.receiver = receiver;
60
}
61![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/** *//**
62
* Class attribute getter
63
* @return the sender
64
*/
65
public String getSender()
66![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
67
return this.sender;
68
}
69![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/** *//**
70
* Class attribute setter
71
* @param sender the sender to set
72
*/
73
public void setSender(String sender)
74![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
75
this.sender = sender;
76
}
77![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/** *//**
78
* Class attribute getter
79
* @return the senderKey
80
*/
81
public long getSenderKey()
82![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
83
return this.senderKey;
84
}
85![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/** *//**
86
* Class attribute setter
87
* @param senderKey the senderKey to set
88
*/
89
public void setSenderKey(long senderKey)
90![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
91
this.senderKey = senderKey;
92
}
93
}
94![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)