Repository navigation
Expand file tree
/
Copy pathUser.java
More file actions
57 lines (53 loc) · 1.69 KB
/
Copy pathUser.java
File metadata and controls
57 lines (53 loc) · 1.69 KB
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
package test;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.Map;
public class User implements Serializable{
String hostName;//计算机名
String username;//用户名
String message;//信息内容
int numbers;//在线人数
int port;
String state="yes";//在线状态
Map<Integer,Integer> al;//记录表情的位置和文件名
public User(String hostName, String username, String message,Map<Integer,Integer> al, int port,String state,int numbers) {
super();
this.hostName = hostName;
this.username = username;
this.message = message;
this.port = port;
this.state=state;
this.al=al;
this.numbers=numbers;
}
public User(String hostName, String username, String message, int port,int numbers) {
super();
this.hostName = hostName;
this.username = username;
this.message = message;
this.port = port;
this.numbers = numbers;
}
private void writeObject(final ObjectOutputStream out) throws IOException {
out.writeUTF(this.hostName);
out.writeUTF(this.username);
out.writeUTF(this.message);
out.writeInt(this.numbers);
out.writeInt(this.port);
out.writeUTF(this.state);
out.writeObject(this.al);
}
//发现发送的信息中大于两位时,服务就报错!!
@SuppressWarnings("unchecked")
private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException {
this.hostName=in.readUTF();
this.username=in.readUTF();
this.message=in.readUTF();
this.numbers=in.readInt();
this.port=in.readInt();
this.state=in.readUTF();
this.al = (Map<Integer, Integer>) in.readObject();
}
}