#99 Added delay of reconnection based on a configurable value.

master
Tomatix 4 years ago
parent 85911009e4
commit 8295794349
  1. 10
      IdealIRC/IRC.cpp

@ -23,6 +23,7 @@
#include "config.h"
#include <fmt/format.h>
#include <QDateTime>
#include <QTimer>
IRC::IRC(IWinStatus& status)
: m_status(status)
@ -152,8 +153,13 @@ void IRC::onDisconnected()
else {
auto& conf = ConfigMgr::instance();
bool reconnect = conf.common("Reconnect").toInt();
if (reconnect && !m_expectDisconnect)
tryConnect();
if (reconnect && !m_expectDisconnect) {
auto delayReconnectSecs = conf.common("ReconnectDelay").toInt();
QTimer::singleShot(delayReconnectSecs * 1000, [this] {
if (!m_expectDisconnect) // Note: This flag might be changed during the timer. If reconnection is aborted, it'll change.
tryConnect();
});
}
}
m_expectDisconnect = false;
}

Loading…
Cancel
Save