broker/MessagesPublisher: code formatter used
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
|
||||||
package io.moquette.spi.impl;
|
package io.moquette.spi.impl;
|
||||||
|
|
||||||
import io.moquette.server.ConnectionDescriptorStore;
|
import io.moquette.server.ConnectionDescriptorStore;
|
||||||
@@ -10,9 +11,7 @@ import io.netty.buffer.ByteBuf;
|
|||||||
import io.netty.handler.codec.mqtt.*;
|
import io.netty.handler.codec.mqtt.*;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static io.moquette.spi.impl.ProtocolProcessor.lowerQosToTheSubscriptionDesired;
|
import static io.moquette.spi.impl.ProtocolProcessor.lowerQosToTheSubscriptionDesired;
|
||||||
|
|
||||||
class MessagesPublisher {
|
class MessagesPublisher {
|
||||||
@@ -35,7 +34,8 @@ class MessagesPublisher {
|
|||||||
return notRetainedPublishWithMessageId(topic, qos, message, 0);
|
return notRetainedPublishWithMessageId(topic, qos, message, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static MqttPublishMessage notRetainedPublishWithMessageId(String topic, MqttQoS qos, ByteBuf message, int messageId) {
|
private static MqttPublishMessage notRetainedPublishWithMessageId(String topic, MqttQoS qos, ByteBuf message,
|
||||||
|
int messageId) {
|
||||||
MqttFixedHeader fixedHeader = new MqttFixedHeader(MqttMessageType.PUBLISH, false, qos, false, 0);
|
MqttFixedHeader fixedHeader = new MqttFixedHeader(MqttMessageType.PUBLISH, false, qos, false, 0);
|
||||||
MqttPublishVariableHeader varHeader = new MqttPublishVariableHeader(topic, messageId);
|
MqttPublishVariableHeader varHeader = new MqttPublishVariableHeader(topic, messageId);
|
||||||
return new MqttPublishMessage(fixedHeader, varHeader, message);
|
return new MqttPublishMessage(fixedHeader, varHeader, message);
|
||||||
@@ -59,11 +59,16 @@ class MessagesPublisher {
|
|||||||
|
|
||||||
boolean targetIsActive = this.connectionDescriptors.isConnected(sub.getClientId());
|
boolean targetIsActive = this.connectionDescriptors.isConnected(sub.getClientId());
|
||||||
|
|
||||||
//we need to retain because duplicate only copy r/w indexes and don't retain() causing refCnt = 0
|
// we need to retain because duplicate only copy r/w indexes and don't retain() causing
|
||||||
|
// refCnt = 0
|
||||||
ByteBuf message = origMessage.retainedDuplicate();
|
ByteBuf message = origMessage.retainedDuplicate();
|
||||||
if (targetIsActive) {
|
if (targetIsActive) {
|
||||||
LOG.debug("Sending PUBLISH message to active subscriber. MessageId={}, CId={}, topicFilter={}, qos={}",
|
LOG.debug(
|
||||||
pubMsg.getMessageID(), sub.getClientId(), sub.getTopicFilter(), qos);
|
"Sending PUBLISH message to active subscriber. MessageId={}, CId={}, topicFilter={}, qos={}",
|
||||||
|
pubMsg.getMessageID(),
|
||||||
|
sub.getClientId(),
|
||||||
|
sub.getTopicFilter(),
|
||||||
|
qos);
|
||||||
MqttPublishMessage publishMsg = notRetainedPublish(topic, qos, message);
|
MqttPublishMessage publishMsg = notRetainedPublish(topic, qos, message);
|
||||||
if (qos != MqttQoS.AT_MOST_ONCE) {
|
if (qos != MqttQoS.AT_MOST_ONCE) {
|
||||||
// QoS 1 or 2
|
// QoS 1 or 2
|
||||||
@@ -75,8 +80,12 @@ class MessagesPublisher {
|
|||||||
this.messageSender.sendPublish(targetSession, publishMsg);
|
this.messageSender.sendPublish(targetSession, publishMsg);
|
||||||
} else {
|
} else {
|
||||||
if (!targetSession.isCleanSession()) {
|
if (!targetSession.isCleanSession()) {
|
||||||
LOG.debug("Storing pending PUBLISH inactive message. MessageId={}, CId={}, topicFilter={}, qos={}",
|
LOG.debug(
|
||||||
pubMsg.getMessageID(), sub.getClientId(), sub.getTopicFilter(), qos);
|
"Storing pending PUBLISH inactive message. MessageId={}, CId={}, topicFilter={}, qos={}",
|
||||||
|
pubMsg.getMessageID(),
|
||||||
|
sub.getClientId(),
|
||||||
|
sub.getTopicFilter(),
|
||||||
|
qos);
|
||||||
// store the message in targetSession queue to deliver
|
// store the message in targetSession queue to deliver
|
||||||
targetSession.enqueue(pubMsg);
|
targetSession.enqueue(pubMsg);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user