@@ -55,6 +55,12 @@ void MQTTBase::addSubcribe(const QString& topic, int qos)
}
+/* 设置自动重连 */
+void MQTTBase::setAutoReconnect(bool isAuto)
+{
+ m_client.setAutoReconnect(isAuto);
+}
+
/* 连接到服务器 */
void MQTTBase::connectToServer()
{
@@ -26,6 +26,8 @@ public:
void setIPAndPort(const QString& IP, int port = 1883);
/* 设置订阅 */
void addSubcribe(const QString& topic,int qos = 0);
+ /* 设置自动重连 */
+ void setAutoReconnect(bool isAuto = true);
void connectToServer();
/* 发送消息 */