-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPacketType.java
More file actions
41 lines (35 loc) · 859 Bytes
/
Copy pathPacketType.java
File metadata and controls
41 lines (35 loc) · 859 Bytes
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
/**
* This class implements an enum containing all the possible Packet Type
* handle by our MQTT broker.
*/
/**
* INFO0010 - Introduction to Computer Networking @Uliège
* Second part of the assignment
* Academic year 2021-2022
* @author Tristan Catteeuw - s161627 | Brieuc Jamoulle - s151977
*/
public enum PacketType {
CONNECT (1),
CONNACK (2),
PUBLISH (3),
SUBSCRIBE (8),
SUBACK (9),
UNSUBSCRIBE (10),
UNSUBACK (11),
PINGREQ (12),
PINGRESP (13),
DISCONNECT (14);
private int value;
PacketType (int value) {
this.value = value;
}
public int getValue() {
return this.value;
}
public static PacketType valueOf(int value) {
for (PacketType p : PacketType.values()) {
if (p.value == value) return p;
}
throw new IllegalArgumentException("Packet Type not valid!");
}
}