#pragma once #include "senderreceiver.hpp" #include "api.h" #include "logging.hpp" #include "client.hpp" #include "connect.hpp" #include "cmix.pb.h" #include #include /*! * \file */ /*! * \brief The NodeDetails struct */ struct NodeDetails { std::string host; ///< The host of the node. std::string port; ///< The port of the node. }; /*! * \brief The NetworkDetails struct */ struct NetworkDetails { std::vector node_details; ///< Vector with all the node hosts and ports in network order. std::string certdir; ///< The directory with trusted certificates. }; /*! * \brief The CMixClient class */ class CMixClient { struct NodeData { void* secret_value; SharedKey shared_value; }; boost::asio::io_service io_service; std::shared_ptr ctx; NetworkDetails network_details; std::vector network_connections; std::vector data; Api api; KeyPair keypair; void key_exchange(size_t node_id); void initialize_connections(); void handle_key_exchange(size_t node_id, cmix_proto::KeyExchange const& ke); void handle_message(size_t node_id, cmix_proto::CMixMessage message); public: /*! * \brief CMixClient * \param details A vector of the connectiondetails for the cmix network */ CMixClient(NetworkDetails details); ~CMixClient(); /*! * \brief run Runs the underlying io_service. */ void run(); };