diff --git a/in.bytehue.messaging.mqtt5.provider/src/main/java/in/bytehue/messaging/mqtt5/provider/command/MqttCommand.java b/in.bytehue.messaging.mqtt5.provider/src/main/java/in/bytehue/messaging/mqtt5/provider/command/MqttCommand.java index 5a0b543..6fe390d 100644 --- a/in.bytehue.messaging.mqtt5.provider/src/main/java/in/bytehue/messaging/mqtt5/provider/command/MqttCommand.java +++ b/in.bytehue.messaging.mqtt5.provider/src/main/java/in/bytehue/messaging/mqtt5/provider/command/MqttCommand.java @@ -42,6 +42,8 @@ import org.osgi.util.converter.Converter; import org.osgi.util.converter.Converters; +import com.hivemq.client.mqtt.MqttClientState; + import in.bytehue.messaging.mqtt5.api.MqttCommandExtension; import in.bytehue.messaging.mqtt5.api.MqttMessageContextBuilder; import in.bytehue.messaging.mqtt5.provider.MessageClientProvider; @@ -97,7 +99,7 @@ public String runtime( table.addRow("Connection URI", runtimeInfo.connectionURI); table.addRow("Connection Port", String.valueOf(client.config().port())); table.addRow("Connection SSL", String.valueOf(client.config().useSSL())); - table.addRow("Connection State", client.client.getState().toString()); + table.addRow("Connection State", getState()); table.addRow("Provider", runtimeInfo.providerName); table.addRow("Supported Protocols", converter.convert(runtimeInfo.protocols).to(String.class)); table.addRow("Instance ID", runtimeInfo.instanceId); @@ -137,7 +139,12 @@ public String runtime( return output.toString(); } - @Descriptor("Subscribes to specific topic/filter with the input context") + private String getState() { + MqttClientState state = client.client.getState(); + return state.isConnected() ? "CONNECTED" : "DISCONNECTED"; + } + + @Descriptor("Subscribes to specific topic/filter with the input context") public String sub( @Descriptor("Topic/Filter")