#include "watchdog_thread.hpp" #include "connection.hpp" #include "irc_parse_thread.hpp" #include using namespace std::chrono_literals; WatchdogThread::WatchdogThread(Connection * connection) noexcept : connection_{connection} { } auto WatchdogThread::priority() const -> priority_type { return 0; } auto WatchdogThread::on_event(Event const& event) -> std::pair { if (auto const irc_event = dynamic_cast(&event)) { timer_.expires_from_now(30s); return {}; } if (auto const connect_event = dynamic_cast(&event)) { timer_.expires_from_now(30s); timer_.async_wait([weak = weak_from_this()](auto error) { if (not error) { if (auto self = weak.lock()) { self->connection_->close(); } } }); } return {}; }