- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMessage.java
More file actions
Latest commit
52 lines (40 loc) · 1.3 KB
/
Copy pathMessage.java
File metadata and controls
52 lines (40 loc) · 1.3 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
/*
* class MESSAGE
* Container for message content & metadata
*/
// Serializable is an interface that requires no methods to be implemented.
// It simply flags an object to be serializable. This is needed to send Messages
// through ObjectOutputStreams.
importjava.io.Serializable;
publicclassMessageimplementsSerializable {
privateString_content;
privateint_senderID; // assigned by server
privateint_receiverID; // assigned by server
// Created through System.currentTimeMillis() / 1000L
privatelong_timestamp;
// Used to set Message IDs
privatestaticintnumberSent;
// Used to verify that no messages came before this one
privateint_id;
// New Message object is created by GUI when sending message and by Server when receiving message
publicMessage(Stringcontent, intsenderID, intreceiverID, longtimestamp) {
_content = content;
_senderID = senderID;
_receiverID = receiverID;
_timestamp = timestamp;
numberSent++;
_id = numberSent;
}
publicintgetSenderID() {
return_senderID;
}
publicintgetReceiverID() {
return_receiverID;
}
publiclonggetTimestamp() {
return_timestamp;
}
publicStringtoString() {
return_content;
}
}