Skip to content

Commit

Permalink
Attempt to reconnect immediately with Qt
Browse files Browse the repository at this point in the history
There's no reason to wait immediately after a disconnect
  • Loading branch information
ungive committed Sep 12, 2024
1 parent db274b8 commit 3d1402f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions client/src/websocket/backend_qt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,13 @@ std::chrono::milliseconds ClientImpl::next_reconnect_delay()
{
using namespace std::chrono_literals;

if (m_reconnect_count > 0 && options().max_reconnect_delay.has_value()) {
auto count = m_reconnect_count;
m_reconnect_count += 1;

if (count == 0) {
return 0ms; // Attempt to reconnect immediately.
}
if (count > 1 && options().max_reconnect_delay.has_value()) {
// Exponentially increase reconnect delay.
auto next = std::min(
options().max_reconnect_delay.value(), 2 * m_reconnect_delay);
Expand All @@ -113,7 +119,6 @@ std::chrono::milliseconds ClientImpl::next_reconnect_delay()
next = std::max(options().reconnect_delay.value(), next);
m_reconnect_delay = next;
}
m_reconnect_count += 1;
return m_reconnect_delay;
}

Expand Down

0 comments on commit 3d1402f

Please sign in to comment.