diff --git a/include/advertiser.h b/include/advertiser.h index 62ab1f6..99d6185 100644 --- a/include/advertiser.h +++ b/include/advertiser.h @@ -24,6 +24,7 @@ #include #include #include +#include /** * @brief A communicator class to update the master server on the server's status. diff --git a/src/advertiser.cpp b/src/advertiser.cpp index 5bc8aec..0f02622 100644 --- a/src/advertiser.cpp +++ b/src/advertiser.cpp @@ -62,6 +62,15 @@ void Advertiser::socketConnected() void Advertiser::socketDisconnected() { qDebug("Connection to master server lost"); + QTimer timer; + while (socket->state() == QAbstractSocket::UnconnectedState) { + timer.start(60000); + QEventLoop timer_loop; + connect(&timer, SIGNAL(timeout()), &timer_loop, SLOT(quit())); + timer_loop.exec(); + socket->connectToHost(ip, port); + socket->waitForConnected(); + } } void Advertiser::reloadRequested(QString p_name, QString p_desc)