refactoring
Some checks failed
BlockStorage/repertory_osx_builds/pipeline/head This commit looks good
BlockStorage/repertory_linux_builds/pipeline/head There was a failure building this commit

This commit is contained in:
2023-12-15 17:58:49 -06:00
parent 34c4a9c508
commit 71686405e0
41 changed files with 1436 additions and 709 deletions

View File

@@ -30,8 +30,7 @@ namespace repertory {
class packet_client final {
private:
struct client final {
explicit client(boost::asio::io_context &ctx) : nonce(""), socket(ctx) {}
explicit client(boost::asio::io_context &ctx) : socket(ctx) {}
std::string nonce;
tcp::socket socket;
};
@@ -43,34 +42,40 @@ public:
~packet_client();
packet_client(const packet_client &) = delete;
packet_client(packet_client &&) = delete;
auto operator=(const packet_client &) -> packet_client & = delete;
auto operator=(packet_client &&) -> packet_client & = delete;
private:
boost::asio::io_context io_context_;
const std::string host_name_or_ip_;
const std::uint8_t max_connections_;
const std::uint16_t port_;
const std::uint16_t receive_timeout_;
const std::uint16_t send_timeout_;
const std::string encryption_token_;
std::string host_name_or_ip_;
std::uint8_t max_connections_;
std::uint16_t port_;
std::uint16_t receive_timeout_;
std::uint16_t send_timeout_;
std::string encryption_token_;
std::string unique_id_;
bool allow_connections_ = true;
private:
bool allow_connections_{true};
boost::asio::ip::basic_resolver<boost::asio::ip::tcp>::results_type
resolve_results_;
std::mutex clients_mutex_;
std::vector<std::shared_ptr<client>> clients_;
private:
void close(client &c) const;
static void close(client &cli);
void close_all();
void connect(client &c);
void connect(client &cli);
[[nodiscard]] auto get_client() -> std::shared_ptr<client>;
void put_client(std::shared_ptr<client> &c);
void put_client(std::shared_ptr<client> &cli);
[[nodiscard]] auto read_packet(client &c, packet &response)
[[nodiscard]] auto read_packet(client &cli, packet &response)
-> packet::error_type;
void resolve();