Skip to content

Commit d1ff104

Browse files
committed
[broker-25] fix for code review
1 parent fd8d24f commit d1ff104

File tree

2 files changed

+12
-15
lines changed

2 files changed

+12
-15
lines changed

src/main/java/com/ss/mqtt/broker/handler/packet/in/ConnectInPacketHandler.java

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ private Mono<Boolean> onConnected(
126126
packet.isRequestProblemInformation()
127127
);
128128

129-
var response = client.getPacketOutFactory().newConnectAck(
129+
var connectAck = client.getPacketOutFactory().newConnectAck(
130130
client,
131131
ConnectAckReasonCode.SUCCESS,
132132
sessionRestored,
@@ -138,17 +138,19 @@ private Mono<Boolean> onConnected(
138138

139139
subscriptionService.restoreSubscriptions(client, session);
140140

141-
return Mono.fromFuture(client.sendWithFeedback(response)
142-
.thenApply(result -> {
141+
return Mono.fromFuture(client.sendWithFeedback(connectAck)
142+
.thenApply(result -> onSentConnAck(client, session, result)));
143+
}
144+
145+
private boolean onSentConnAck(@NotNull UnsafeMqttClient client, @NotNull MqttSession session, boolean result) {
143146

144-
if (!result) {
145-
log.warn("Was issue with sending conn ack packet to client {}", client.getClientId());
146-
return false;
147-
}
147+
if (!result) {
148+
log.warn("Was issue with sending conn ack packet to client {}", client.getClientId());
149+
return false;
150+
}
148151

149-
session.resendPendingPackets(client);
150-
return true;
151-
}));
152+
session.resendPendingPackets(client);
153+
return true;
152154
}
153155

154156
private boolean checkPacketException(@NotNull UnsafeMqttClient client, @NotNull ConnectInPacket packet) {

src/main/java/com/ss/mqtt/broker/network/packet/out/Connect311OutPacket.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,8 @@ protected void writePayload(@NotNull ByteBuffer buffer) {
7272

7373
// http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html#_Toc398718031
7474
writeString(buffer, clientId);
75-
76-
// for MQTT 5
7775
if (StringUtils.isNotEmpty(willTopic)) {
7876
appendWillProperties(buffer);
79-
}
80-
81-
if (StringUtils.isNotEmpty(willTopic)) {
8277
writeString(buffer, willTopic);
8378
writeBytes(buffer, willPayload);
8479
}

0 commit comments

Comments
 (0)