refactoring
This commit is contained in:
@@ -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();
|
||||
|
Reference in New Issue
Block a user