MCPcopy Create free account
hub / github.com/KDE/labplot / removeClient

Method removeClient

src/frontend/dockwidgets/LiveDataDock.cpp:780–806  ·  view source on GitHub ↗

! *\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 */

Source from the content-addressed store, hash-verified

778 * \param name the host name of the MQTTClient that will be deleted
779 */
780void 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

Callers

nothing calls this directly

Calls 4

clientHostNameMethod · 0.80
eraseMethod · 0.80
endMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected