#pragma once #include #include #include #include #include struct event_base; namespace ts { namespace server { class TSServer; } namespace weblist { class TSWebClient; class WebListManager { private: struct Entry { std::shared_ptr server; std::shared_ptr current_request; std::chrono::system_clock::time_point last_success; std::chrono::system_clock::time_point scheduled_request; int fail_count = 0; uint16_t session_count = 1; std::string last_name; }; public: WebListManager(); ~WebListManager(); void enable_report(const std::shared_ptr& /* server */); bool reports_enabled(const std::shared_ptr& /* server */); void disable_report(const std::shared_ptr& /* server */); void tick(); bool enabled = false; private: struct event_base* event_base = nullptr; std::thread event_base_dispatch; std::mutex entry_lock; std::deque> entries; }; } }