Teaspeak-Server/server/src/weblist/WebListManager.h

50 lines
1.5 KiB
C
Raw Normal View History

#pragma once
#include <thread>
#include <memory>
#include <chrono>
#include <mutex>
#include <deque>
2020-03-02 07:33:57 -05:00
#include <condition_variable>
struct event_base;
namespace ts {
2020-01-23 20:57:58 -05:00
namespace server {
2020-01-26 12:04:38 -05:00
class VirtualServer;
2020-01-23 20:57:58 -05:00
}
namespace weblist {
class TSWebClient;
class WebListManager {
private:
struct Entry {
2020-01-26 12:04:38 -05:00
std::shared_ptr<server::VirtualServer> server;
2020-01-23 20:57:58 -05:00
std::shared_ptr<TSWebClient> 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();
2020-01-26 12:04:38 -05:00
void enable_report(const std::shared_ptr<server::VirtualServer>& /* server */);
bool reports_enabled(const std::shared_ptr<server::VirtualServer>& /* server */);
void disable_report(const std::shared_ptr<server::VirtualServer>& /* server */);
2020-01-23 20:57:58 -05:00
void tick();
bool enabled = false;
private:
2020-02-21 14:32:25 -05:00
struct event_base* event_base{nullptr};
std::thread event_base_dispatch{};
2020-01-23 20:57:58 -05:00
2020-02-21 14:32:25 -05:00
std::mutex entry_lock{};
std::condition_variable entry_cv{};
std::deque<std::shared_ptr<Entry>> entries{};
2020-01-23 20:57:58 -05:00
};
}
}