-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMessage.java
87 lines (74 loc) · 1.62 KB
/
Message.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/**
* VERIFICATION is for shake hand message when connecting with server and clinet
* NOTIFICATION is for someone joining or leaving chat room
* TEXT is for regular chat message
* type of <code>Message</code>
*/
enum MessageType{
VERIFICATION,
NOTIFICATION,
TEXT
}
/**
* capsulate chatting message
*/
class Message implements java.io.Serializable{
private MessageType type;
private String text;
private String sender;
private int threadId;
private int numOfOnlinePeople;
/**
* Constructor of <code>Message</code>
* @param type <code>Message</code> type
* @param text <code>Message</code> text
* @param sender <code>Message</code> sender user name
*/
public Message(MessageType type,String text, String sender){
this.type = type;
this.text = text;
this.sender = sender;
}
/**
* @return type <code>Message</code> type
*/
public MessageType getType() {
return type;
}
/**
* @return text <code>Message</code> text
*/
public String getContent() {
return text;
}
/**
* @return sender <code>Message</code> sender user
*/
public String getSender() {
return sender;
}
/**
* @param threadId hashCode of a specifc thread
*/
public void setThreadId(int threadId){
this.threadId = threadId;
}
/**
* @return threadId hashCode of a specifc thread
*/
public int getThreadId(){
return this.threadId;
}
/**
* @param numOfOnlinePeople set number of online people
*/
public void setNumOfOnlinePeople(int num){
this.numOfOnlinePeople = num;
}
/**
* @return numOfOnlinePeople get number of online people
*/
public int getNumOfOnlinePeople(){
return this.numOfOnlinePeople;
}
}