MqttMonitor/MqttMonitorWidget.py

branch
eric7
changeset 101
0eae5f616154
parent 100
9c29cfbd96c3
child 102
70b8858199f5
equal deleted inserted replaced
100:9c29cfbd96c3 101:0eae5f616154
251 # TODO: add support for flags[‘session present’] 251 # TODO: add support for flags[‘session present’]
252 if rc == 0: 252 if rc == 0:
253 self.__connectedToBroker = True 253 self.__connectedToBroker = True
254 self.__connectionOptions = None 254 self.__connectionOptions = None
255 255
256 if packetType is not None: 256 msg = (
257 msg = mqttReasonCode(rc, packetType) 257 mqttReasonCode(rc, packetType)
258 else: 258 if packetType is not None else
259 msg = mqttConnackMessage(rc) 259 mqttConnackMessage(rc)
260 )
260 self.__flashBrokerStatusLabel(msg) 261 self.__flashBrokerStatusLabel(msg)
261 262
262 self.connectButton.setEnabled(True) 263 self.connectButton.setEnabled(True)
263 if rc == 0: 264 if rc == 0:
264 self.__connectedToBroker = True 265 self.__connectedToBroker = True
292 """ 293 """
293 Private slot to handle a disconnection from the broker. 294 Private slot to handle a disconnection from the broker.
294 295
295 @param rc MQTT error result code 296 @param rc MQTT error result code
296 @type int 297 @type int
298 @param packetType packet type as reported by the client
299 @type int
297 """ 300 """
298 self.__connectedToBroker = False 301 self.__connectedToBroker = False
299 302
300 # ensure, the client loop is stopped 303 # ensure, the client loop is stopped
301 self.__client.stopLoop() 304 self.__client.stopLoop()
302 305
303 if packetType is not None: 306 msg = (
304 # MQTT v5 307 # MQTT v5
305 msg = mqttReasonCode(rc, packetType) 308 mqttReasonCode(rc, packetType)
306 else: 309 if packetType is not None else
307 # MQTT v3 310 # MQTT v3
308 msg = ( 311 (
309 mqttErrorMessage(rc) 312 mqttErrorMessage(rc)
310 if rc > 0 else 313 if rc > 0 else
311 self.tr("Connection to Broker shut down cleanly.") 314 self.tr("Connection to Broker shut down cleanly.")
312 ) 315 )
316 )
313 self.__flashBrokerStatusLabel(msg) 317 self.__flashBrokerStatusLabel(msg)
314 318
315 self.connectButton.setIcon(UI.PixmapCache.getIcon("ircConnect")) 319 self.connectButton.setIcon(UI.PixmapCache.getIcon("ircConnect"))
316 self.__setConnectButtonState() 320 self.__setConnectButtonState()
317 321
369 else: 373 else:
370 self.logEdit.verticalScrollBar().setValue(scrollbarValue) 374 self.logEdit.verticalScrollBar().setValue(scrollbarValue)
371 375
372 # TODO: add support for MQTT v5 properties 376 # TODO: add support for MQTT v5 properties
373 @pyqtSlot(str, bytes, int, bool) 377 @pyqtSlot(str, bytes, int, bool)
378 @pyqtSlot(str, bytes, int, bool, dict)
374 def __messageReceived(self, topic, payload, qos, retain, properties=None): 379 def __messageReceived(self, topic, payload, qos, retain, properties=None):
375 """ 380 """
376 Private slot to handle the receipt of a message. 381 Private slot to handle the receipt of a message.
377 382
378 @param topic topic of the message 383 @param topic topic of the message
410 Private slot to handle being subscribed to topics (MQTT v3.1, 415 Private slot to handle being subscribed to topics (MQTT v3.1,
411 MQTT v3.1.1). 416 MQTT v3.1.1).
412 417
413 @param mid ID of the subscribe request 418 @param mid ID of the subscribe request
414 @type int 419 @type int
415 @param grantedQos tuple of granted quality of service
416 @type tuple of int
417 """ 420 """
418 if mid in self.__topicQueue: 421 if mid in self.__topicQueue:
419 topic = self.__topicQueue.pop(mid) 422 topic = self.__topicQueue.pop(mid)
420 self.__subscribedTopics.append(topic) 423 self.__subscribedTopics.append(topic)
421 self.subscribeTopicEdit.clear() 424 self.subscribeTopicEdit.clear()
947 @param qos quality of service indicator (0, 1, 2) 950 @param qos quality of service indicator (0, 1, 2)
948 @type int 951 @type int
949 @param retain flag indicating a retained message 952 @param retain flag indicating a retained message
950 @type bool 953 @type bool
951 @param properties properties sent with the message (MQTT v5) 954 @param properties properties sent with the message (MQTT v5)
952 @type Properties 955 @type dict
953 """ 956 """
954 # TODO: add Output for retain and properties 957 # TODO: add Output for properties
955 scrollbarValue = self.messagesEdit.verticalScrollBar().value() 958 scrollbarValue = self.messagesEdit.verticalScrollBar().value()
956 959
957 textCursor = self.messagesEdit.textCursor() 960 textCursor = self.messagesEdit.textCursor()
958 if not self.messagesEdit.document().isEmpty(): 961 if not self.messagesEdit.document().isEmpty():
959 textCursor.movePosition(QTextCursor.MoveOperation.End) 962 textCursor.movePosition(QTextCursor.MoveOperation.End)

eric ide

mercurial