-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConnectVH.java
More file actions
151 lines (129 loc) · 3.58 KB
/
ConnectVH.java
File metadata and controls
151 lines (129 loc) · 3.58 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
/**
* This class implements the variable header structure of a CONNECT message.
*/
/**
* INFO0010 - Introduction to Computer Networking @Uliège
* Second part of the assignment
* Academic year 2021-2022
* @author Tristan Catteeuw - s161627 | Brieuc Jamoulle - s151977
*/
public class ConnectVH {
private final String protocol;
private final int version;
private final boolean username;
private final boolean password;
private final boolean willRetain;
private final QoS qos;
private final boolean willFlag;
private final boolean cleanSessionFlag;
/**
* Constructor of a CONNECT variable header object.
*
* @param protocol The protocol name
* @param version Revision level of the protocol used by the Client
* @param username The user name of the client
* @param password The password of the client
* @param willRetain Specifies if the Will Message is to be Retained when it is published
* @param qos Specify the QoS level to be used when publishing the Will Message
* @param willFlag Specifies if the Will Message is to be Retained when it is published
* @param cleanSessionFlag TODO
*/
public ConnectVH(
String protocol,
int version,
boolean username,
boolean password,
boolean willRetain,
QoS qos,
boolean willFlag,
boolean cleanSessionFlag){
this.protocol = protocol;
this.version = version;
this.username = username;
this.password = password;
this.willRetain = willRetain;
this.qos = qos;
this.willFlag = willFlag;
this.cleanSessionFlag = cleanSessionFlag;
}
/**
* Getter of the protocol variable
*
* @return String
*/
public String getProtocol() {
return protocol;
}
/**
* Getter of the version variable
*
* @return int
*/
public int getVersion() {
return version;
}
/**
* Getter of the username variable
*
* @return boolean
*/
public boolean isUsername() {
return username;
}
/**
* Getter of the password variable
*
* @return boolean
*/
public boolean isPassword() {
return password;
}
/**
* Getter of the will retain
*
* @return boolean
*/
public boolean isWillRetain() {
return willRetain;
}
/**
* Getter of the QoS
*
* @return QoS
*/
public QoS getQos() {
return qos;
}
/**
* Getter of the will flag
*
* @return boolean
*/
public boolean isWillFlag() {
return willFlag;
}
/**
* Getter of the clean session flag
*
* @return boolean
*/
public boolean isCleanSessionFlag() {
return cleanSessionFlag;
}
/**
* @return String
*/
@Override
public String toString() {
return "{" +
" protocol='" + getProtocol() + "'" +
", version='" + getVersion() + "'" +
", username='" + isUsername() + "'" +
", password='" + isPassword() + "'" +
", willRetain='" + isWillRetain() + "'" +
", qos='" + getQos() + "'" +
", willFlag='" + isWillFlag() + "'" +
", cleanSessionFlag='" + isCleanSessionFlag() + "'" +
"}";
}
}