MqttMonitor/MqttMonitorWidget.py

branch
eric7
changeset 101
0eae5f616154
parent 100
9c29cfbd96c3
child 102
70b8858199f5
--- a/MqttMonitor/MqttMonitorWidget.py	Tue Jul 20 17:48:21 2021 +0200
+++ b/MqttMonitor/MqttMonitorWidget.py	Tue Jul 20 18:10:55 2021 +0200
@@ -253,10 +253,11 @@
             self.__connectedToBroker = True
             self.__connectionOptions = None
         
-        if packetType is not None:
-            msg = mqttReasonCode(rc, packetType)
-        else:
-            msg = mqttConnackMessage(rc)
+            msg = (
+                mqttReasonCode(rc, packetType)
+                if packetType is not None else
+                mqttConnackMessage(rc)
+            )
         self.__flashBrokerStatusLabel(msg)
         
         self.connectButton.setEnabled(True)
@@ -294,22 +295,25 @@
         
         @param rc MQTT error result code
         @type int
+        @param packetType packet type as reported by the client
+        @type int
         """
         self.__connectedToBroker = False
         
         # ensure, the client loop is stopped
         self.__client.stopLoop()
         
-        if packetType is not None:
+        msg = (
             # MQTT v5
-            msg = mqttReasonCode(rc, packetType)
-        else:
+            mqttReasonCode(rc, packetType)
+            if packetType is not None else
             # MQTT v3
-            msg = (
+            (
                 mqttErrorMessage(rc)
                 if rc > 0 else
                 self.tr("Connection to Broker shut down cleanly.")
             )
+        )
         self.__flashBrokerStatusLabel(msg)
         
         self.connectButton.setIcon(UI.PixmapCache.getIcon("ircConnect"))
@@ -371,6 +375,7 @@
     
     # TODO: add support for MQTT v5 properties
     @pyqtSlot(str, bytes, int, bool)
+    @pyqtSlot(str, bytes, int, bool, dict)
     def __messageReceived(self, topic, payload, qos, retain, properties=None):
         """
         Private slot to handle the receipt of a message.
@@ -412,8 +417,6 @@
         
         @param mid ID of the subscribe request
         @type int
-        @param grantedQos tuple of granted quality of service
-        @type tuple of int
         """
         if mid in self.__topicQueue:
             topic = self.__topicQueue.pop(mid)
@@ -949,9 +952,9 @@
         @param retain flag indicating a retained message
         @type bool
         @param properties properties sent with the message (MQTT v5)
-        @type Properties
+        @type dict
         """
-        # TODO: add Output for retain and properties
+        # TODO: add Output for properties
         scrollbarValue = self.messagesEdit.verticalScrollBar().value()
         
         textCursor = self.messagesEdit.textCursor()

eric ide

mercurial