-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMessage.java
More file actions
70 lines (52 loc) · 1.31 KB
/
Message.java
File metadata and controls
70 lines (52 loc) · 1.31 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
58
59
60
61
62
63
64
65
66
67
68
69
70
// Message class. Two constructors, one for each primary type of message
public class Message {
Integer dack;
Integer dsn;
byte[] data;
Integer length;
ConnID cID;
enum Command {
ACCEPT, CLOSE, UPDATE_WINDOW
}
boolean DATAFIN = false;
Command command;
public Message(byte[] data, Integer dsn, Integer length) {
this.data = data;
this.dsn = dsn;
this.length = length;
};
public Message(byte[] data, Integer dsn, Integer length, ConnID cID) {
this.data = data;
this.dsn = dsn;
this.length = length;
this.cID = cID;
};
public Message(byte[] data, Integer dsn, Integer length, boolean finish){
this.data = data;
this.dsn = dsn;
this.length = length;
this.DATAFIN = finish;
};
public Message(Integer dack){
this.dack = dack;
}
public Message(Command command) {
this.command = command;
}
public Message(Command command, int dack){
this.command = command;
this.dack = dack;
}
public int getSize() {
return length;
}
public boolean getDATAFIN(){
return DATAFIN;
}
public Command getCommand(){
return command;
}
public int getDSN() {
return this.dsn;
}
}