Skip to content

Commit 66489ec

Browse files
committed
refactoring
1 parent 38f77f8 commit 66489ec

15 files changed

+30
-43
lines changed

src/main/java/com/ss/mqtt/broker/model/ConnectAckReasonCode.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public enum ConnectAckReasonCode {
1212
/**
1313
* The Connection is accepted.
1414
*/
15-
SUCCESSFUL((byte) 0x00, (byte) 0x00),
15+
SUCCESS((byte) 0x00, (byte) 0x00),
1616

1717
// WITH REASONS BELOW SERVER MUST CLOSE CONNECTION
1818

@@ -141,7 +141,7 @@ public enum ConnectAckReasonCode {
141141
public static @NotNull ConnectAckReasonCode ofMqtt311(int reasonCode) {
142142
switch (reasonCode) {
143143
case 0x00:
144-
return SUCCESSFUL;
144+
return SUCCESS;
145145
case 0x01:
146146
return UNSUPPORTED_PROTOCOL_VERSION;
147147
case 0x02:

src/main/java/com/ss/mqtt/broker/model/PublishAckReasonCode.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public enum PublishAckReasonCode {
1313
* The message is accepted. Publication of the QoS 1
1414
* message proceeds.
1515
*/
16-
SUCCESSFUL((byte) 0x00),
16+
SUCCESS((byte) 0x00),
1717
/**
1818
* The message is accepted but there are no
1919
* subscribers. This is sent only by the Server. If the

src/main/java/com/ss/mqtt/broker/network/MqttClient.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
import lombok.extern.log4j.Log4j2;
1414
import org.jetbrains.annotations.NotNull;
1515

16-
import java.util.Objects;
17-
1816
@Log4j2
1917
@Getter
2018
@EqualsAndHashCode(of = "clientId")
@@ -65,7 +63,7 @@ private void onConnected(@NotNull ConnectInPacket connect) {
6563

6664
connection.send(getPacketOutFactory().newConnectAck(
6765
this,
68-
ConnectAckReasonCode.SUCCESSFUL,
66+
ConnectAckReasonCode.SUCCESS,
6967
false,
7068
clientId,
7169
sessionExpiryInterval,

src/main/java/com/ss/mqtt/broker/network/packet/in/AuthenticationInPacket.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ public class AuthenticationInPacket extends MqttReadablePacket {
5555

5656
private @NotNull AuthenticateReasonCode reasonCode;
5757

58+
// properties
5859
private @NotNull String reason;
5960
private @NotNull String authenticationMethod;
6061

src/main/java/com/ss/mqtt/broker/network/packet/in/ConnectAckInPacket.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ public class ConnectAckInPacket extends MqttReadablePacket {
267267
public ConnectAckInPacket(byte info) {
268268
super(info);
269269
this.userProperties = Array.empty();
270-
this.reasonCode = ConnectAckReasonCode.SUCCESSFUL;
270+
this.reasonCode = ConnectAckReasonCode.SUCCESS;
271271
this.maximumQos = QoS.EXACTLY_ONCE_DELIVERY;
272272
this.sessionExpiryInterval = MqttPropertyConstants.SESSION_EXPIRY_INTERVAL_DEFAULT;
273273
this.receiveMax = MqttPropertyConstants.RECEIVE_MAXIMUM_DEFAULT;

src/main/java/com/ss/mqtt/broker/network/packet/in/DisconnectInPacket.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ public class DisconnectInPacket extends MqttReadablePacket {
5757

5858
private @NotNull DisconnectReasonCode reasonCode;
5959

60+
// properties
6061
private @NotNull String reason;
6162
private @NotNull String serverReference;
6263

src/main/java/com/ss/mqtt/broker/network/packet/in/PublishAckInPacket.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public class PublishAckInPacket extends MqttReadablePacket {
5151

5252
public PublishAckInPacket(byte info) {
5353
super(info);
54-
this.reasonCode = PublishAckReasonCode.SUCCESSFUL;
54+
this.reasonCode = PublishAckReasonCode.SUCCESS;
5555
this.reason = StringUtils.EMPTY;
5656
}
5757

src/main/java/com/ss/mqtt/broker/network/packet/in/PublishCompleteInPacket.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,11 @@ public class PublishCompleteInPacket extends MqttReadablePacket {
4444
);
4545

4646
private @NotNull PublishCompletedReasonCode reasonCode;
47-
private @NotNull String reason;
48-
4947
private int packetId;
5048

49+
// properties
50+
private @NotNull String reason;
51+
5152
public PublishCompleteInPacket(byte info) {
5253
super(info);
5354
this.reasonCode = PublishCompletedReasonCode.SUCCESS;

src/main/java/com/ss/mqtt/broker/network/packet/in/PublishInPacket.java

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -230,11 +230,6 @@ public class PublishInPacket extends MqttReadablePacket {
230230
*/
231231
private final boolean retained;
232232

233-
/**
234-
* The list of subscription ids.
235-
*/
236-
private @NotNull IntegerArray subscriptionIds;
237-
238233
/**
239234
* The Topic Name identifies the information channel to which Payload data is published.
240235
* <p>
@@ -255,34 +250,23 @@ public class PublishInPacket extends MqttReadablePacket {
255250
private @NotNull String topicName;
256251

257252
/**
258-
* The response topic.
253+
* The Packet Identifier field is only present in PUBLISH packets where the QoS level is 1 or 2. Section
254+
* 2.2.1 provides more information about Packet Identifiers.
259255
*/
260-
private @NotNull String responseTopic;
256+
private int packetId;
261257

262-
/**
263-
* The content type.
264-
*/
265-
private @NotNull String contentType;
258+
private @NotNull byte[] payload;
266259

267-
/**
268-
* The correlation data.
269-
*/
270-
private @NotNull byte[] correlationData;
260+
// properties
261+
private @NotNull String responseTopic;
262+
private @NotNull String contentType;
271263

272-
/**
273-
* The payload data.
274-
*/
275-
private @NotNull byte[] payload;
264+
private @NotNull IntegerArray subscriptionIds;
276265

277-
/**
278-
* The Packet Identifier field is only present in PUBLISH packets where the QoS level is 1 or 2. Section
279-
* 2.2.1 provides more information about Packet Identifiers.
280-
*/
281-
private int packetId;
266+
private @NotNull byte[] correlationData;
282267

283268
private long messageExpiryInterval = MqttPropertyConstants.MESSAGE_EXPIRY_INTERVAL_DEFAULT;
284269
private int topicAlias = MqttPropertyConstants.TOPIC_ALIAS_DEFAULT;
285-
286270
private boolean payloadFormatIndicator = MqttPropertyConstants.PAYLOAD_FORMAT_INDICATOR_DEFAULT;
287271

288272
public PublishInPacket(byte info) {

src/main/java/com/ss/mqtt/broker/network/packet/in/PublishReceivedInPacket.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,11 @@ public class PublishReceivedInPacket extends MqttReadablePacket {
4444
);
4545

4646
private @NotNull PublishReceivedReasonCode reasonCode;
47-
private @NotNull String reason;
48-
4947
private int packetId;
5048

49+
// properties
50+
private @NotNull String reason;
51+
5152
public PublishReceivedInPacket(byte info) {
5253
super(info);
5354
this.reasonCode = PublishReceivedReasonCode.SUCCESS;

0 commit comments

Comments
 (0)