1 /*
2 * Copyright 2014 The Netty Project
3 *
4 * The Netty Project licenses this file to you under the Apache License,
5 * version 2.0 (the "License"); you may not use this file except in compliance
6 * with the License. You may obtain a copy of the License at:
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 * License for the specific language governing permissions and limitations
14 * under the License.
15 */
16
17 package io.netty.handler.codec.mqtt;
18
19 /**
20 * MQTT Message Types.
21 */
22 public enum MqttMessageType {
23 CONNECT(1),
24 CONNACK(2),
25 PUBLISH(3),
26 PUBACK(4),
27 PUBREC(5),
28 PUBREL(6),
29 PUBCOMP(7),
30 SUBSCRIBE(8),
31 SUBACK(9),
32 UNSUBSCRIBE(10),
33 UNSUBACK(11),
34 PINGREQ(12),
35 PINGRESP(13),
36 DISCONNECT(14);
37
38 private final int value;
39
40 MqttMessageType(int value) {
41 this.value = value;
42 }
43
44 public int value() {
45 return value;
46 }
47
48 public static MqttMessageType valueOf(int type) {
49 for (MqttMessageType t : values()) {
50 if (t.value == type) {
51 return t;
52 }
53 }
54 throw new IllegalArgumentException("unknown message type: " + type);
55 }
56 }
57