Program Listing for File trickle_manager.hpp
↰ Return to documentation for file (trickle/trickle_manager.hpp)
#ifndef TRICKLE_MANAGER_HPP_
#define TRICKLE_MANAGER_HPP_
#include <atomic>
#include <cassert>
#include <format>
#include <memory>
#include <numeric>
#include "nlohmann/json.hpp"
#include "fromhost_buffer.hpp"
#include "receiver.hpp"
#include "elink.hpp"
#include "ers/ers.h"
#include "felix/felix_toflx.hpp"
namespace trickle {
ERS_DECLARE_ISSUE(felix_log, trickle_manager_issue, issue_message, ((const std::string&)issue_message))
template <class Buffer>
class TrickleManager {
public:
TrickleManager(std::shared_ptr<Buffer> buffer, std::unique_ptr<Receiver> receiver);
TrickleManager(const TrickleManager&) = delete;
TrickleManager& operator=(const TrickleManager&) = delete;
TrickleManager(TrickleManager&&) noexcept = default;
TrickleManager& operator=(TrickleManager&&) noexcept = default;
[[nodiscard]] uint16_t get_receiver_port() const {
return m_receiver->get_port();
};
private:
void connection_established(const std::string& s){ERS_INFO(std::format("[Trickle] Connection established. Conn. info from receiver: {}", s));};
void connection_closed(const std::string& s){ERS_INFO(std::format("[Trickle] Connection closed. Conn. info from receiver: {}", s));};
void message_received(const std::vector<ToFlxMessage>& messages);
void process_message(const ToFlxMessage& message);
void handle_send_config(const nlohmann::json &command);
void start_trickle();
void stop_trickle();
void select_bcids(const nlohmann::json &command);
void throttle(const nlohmann::json &command);
void add_padding();
constexpr static uint32_t MAX_BCID = 3654;
uint32_t m_first_bcid{0};
uint32_t m_last_bcid{MAX_BCID};
uint32_t m_throttle_factor{1};
std::shared_ptr<Buffer> m_buffer{};
std::unique_ptr<Receiver> m_receiver{};
};
} // namespace trickle
#endif /* TRICKLE_MANAGER_HPP_ */