Files
roro9stack/lib/irc/src/reconnect_policy.h
T
twislaandClaude Opus 5.5 311eb38723 M1 step 4a: IRC protocol core (host-tested)
lib/irc: IrcMessage parse/serialize, base64, ReconnectPolicy
(5 s .. 5 min), IrcConfig (validated, persisted) and IrcSession:
registration with SASL PLAIN or NickServ, nick fallback, PING, Buffers
capped at 50 lines with unread counts, Mentions, CTCP ACTION/VERSION,
topics, /names on request only, others' join/part/quit hidden, user
commands, and rejoining after a pause. No networking: the session
returns lines to send, Log entries and Notifications.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EhqxQ49eCju4CzKYNjZzwT
2026-10-02 15:03:21 +02:00

22 lines
516 B
C++

#pragma once
#include <cstdint>
namespace roro {
// Waits between IRC reconnection attempts: 5 s, 10 s, 30 s, 1 min, 2 min, then every 5 min.
class ReconnectPolicy {
public:
uint32_t nextDelayMs() {
static const uint32_t kDelays[] = {5000, 10000, 30000, 60000, 120000, 300000};
const int n = sizeof(kDelays) / sizeof(kDelays[0]);
return kDelays[attempt_ < n ? attempt_++ : n - 1];
}
void reset() { attempt_ = 0; }
private:
int attempt_ = 0;
};
} // namespace roro