2023-11-25 09:22:55 -08:00
|
|
|
#pragma once
|
|
|
|
|
2023-11-27 14:12:20 -08:00
|
|
|
#include <boost/asio/steady_timer.hpp>
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
|
2023-11-25 09:22:55 -08:00
|
|
|
class Connection;
|
2023-11-27 14:12:20 -08:00
|
|
|
|
|
|
|
class WatchdogThread : std::enable_shared_from_this<WatchdogThread>
|
|
|
|
{
|
|
|
|
Connection& connection_;
|
|
|
|
boost::asio::steady_timer timer_;
|
|
|
|
bool tried_ping;
|
|
|
|
|
|
|
|
auto on_activity() -> void;
|
|
|
|
auto timeout_token();
|
|
|
|
auto on_timeout() -> void;
|
|
|
|
auto on_connect() -> void;
|
|
|
|
auto on_disconnect() -> void;
|
|
|
|
|
|
|
|
public:
|
|
|
|
WatchdogThread(Connection& connection);
|
|
|
|
static auto start(Connection& connection) -> void;
|
|
|
|
};
|