! *\brief called when an MQTTClient is about to be deleted * removes every data connected to the MQTTClient, and disconnects the corresponding client from the host * * \param hostname the host name of the MQTTClient that will be deleted * \param name the host name of the MQTTClient that will be deleted */
| 778 | * \param name the host name of the MQTTClient that will be deleted |
| 779 | */ |
| 780 | void LiveDataDock::removeClient(const QString& hostname, quint16 port) { |
| 781 | auto it = m_hosts.find(qMakePair(hostname, port)); |
| 782 | if (it == m_hosts.end()) |
| 783 | return; |
| 784 | |
| 785 | MQTTHost& host = it.value(); |
| 786 | |
| 787 | if (host.count > 1) { |
| 788 | --host.count; |
| 789 | return; |
| 790 | } |
| 791 | |
| 792 | host.client->disconnectFromHost(); |
| 793 | |
| 794 | if (m_previousMQTTClient && m_previousMQTTClient->clientHostName() == hostname) { |
| 795 | disconnect(m_previousHost->client, &QMqttClient::messageReceived, this, &LiveDataDock::mqttMessageReceivedInBackground); |
| 796 | m_previousMQTTClient = nullptr; |
| 797 | } |
| 798 | |
| 799 | if (m_mqttClient && m_mqttClient->clientHostName() == hostname) { |
| 800 | Q_EMIT MQTTClearTopics(); |
| 801 | m_mqttClient = nullptr; |
| 802 | } |
| 803 | |
| 804 | delete host.client; |
| 805 | m_hosts.erase(it); |
| 806 | } |
| 807 | |
| 808 | /*! |
| 809 | * \brief Used for testing the MQTT related features |
nothing calls this directly
no test coverage detected