-
Notifications
You must be signed in to change notification settings - Fork 0
/
ClientThread.java
57 lines (51 loc) · 1.91 KB
/
ClientThread.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import java.util.StringTokenizer;
import java.util.Vector;
import java.io.DataInputStream;
class ClientThread implements Runnable
{
DataInputStream dis;
MyClient client;
ClientThread(final DataInputStream dis, final MyClient client) {
this.dis = dis;
this.client = client;
}
public void run() {
Label_0003_Outer:
while (true) {
while (true) {
try {
while (true) {
final String utf = this.dis.readUTF();
if (utf.startsWith("updateuserslist:")) {
this.updateUsersList(utf);
}
else {
if (utf.equals("@@logoutme@@:")) {
break;
}
this.client.txtBroadcast.append("\n" + utf);
}
this.client.txtBroadcast.setCaretPosition(this.client.txtBroadcast.getLineStartOffset(this.client.txtBroadcast.getLineCount() - 1));
}
break;
}
catch (Exception obj) {
this.client.txtBroadcast.append("\nClientThread run : " + obj);
continue Label_0003_Outer;
}
continue;
}
}
}
public void updateUsersList(String str) {
final Vector<String> listData = new Vector<String>();
str = str.replace("[", "");
str = str.replace("]", "");
str = str.replace("updateuserslist:", "");
final StringTokenizer stringTokenizer = new StringTokenizer(str, ",");
while (stringTokenizer.hasMoreTokens()) {
listData.add(stringTokenizer.nextToken());
}
this.client.usersList.setListData(listData);
}
}