Skip to content

Commit 76c9588

Browse files
committed
[QRT-4729] Added feature to show only CONNECTED and DISCONNECTED states
1 parent df7cea8 commit 76c9588

File tree

1 file changed

+9
-2
lines changed
  • in.bytehue.messaging.mqtt5.provider/src/main/java/in/bytehue/messaging/mqtt5/provider/command

1 file changed

+9
-2
lines changed

in.bytehue.messaging.mqtt5.provider/src/main/java/in/bytehue/messaging/mqtt5/provider/command/MqttCommand.java

+9-2
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@
4242
import org.osgi.util.converter.Converter;
4343
import org.osgi.util.converter.Converters;
4444

45+
import com.hivemq.client.mqtt.MqttClientState;
46+
4547
import in.bytehue.messaging.mqtt5.api.MqttCommandExtension;
4648
import in.bytehue.messaging.mqtt5.api.MqttMessageContextBuilder;
4749
import in.bytehue.messaging.mqtt5.provider.MessageClientProvider;
@@ -97,7 +99,7 @@ public String runtime(
9799
table.addRow("Connection URI", runtimeInfo.connectionURI);
98100
table.addRow("Connection Port", String.valueOf(client.config().port()));
99101
table.addRow("Connection SSL", String.valueOf(client.config().useSSL()));
100-
table.addRow("Connection State", client.client.getState().toString());
102+
table.addRow("Connection State", getState());
101103
table.addRow("Provider", runtimeInfo.providerName);
102104
table.addRow("Supported Protocols", converter.convert(runtimeInfo.protocols).to(String.class));
103105
table.addRow("Instance ID", runtimeInfo.instanceId);
@@ -137,7 +139,12 @@ public String runtime(
137139
return output.toString();
138140
}
139141

140-
@Descriptor("Subscribes to specific topic/filter with the input context")
142+
private String getState() {
143+
MqttClientState state = client.client.getState();
144+
return state.isConnected() ? "CONNECTED" : "DISCONNECTED";
145+
}
146+
147+
@Descriptor("Subscribes to specific topic/filter with the input context")
141148
public String sub(
142149

143150
@Descriptor("Topic/Filter")

0 commit comments

Comments
 (0)