#pragma once #include "Socket.hpp" #include "DirectConnection.hpp" #include "IpAddress.hpp" #include "PubsubKey.hpp" #include #include namespace sibs { class BootstrapException : public std::runtime_error { public: BootstrapException(const std::string &errMsg) : std::runtime_error(errMsg) {} }; class BootstrapNode { DISABLE_COPY(BootstrapNode) public: // Throws SocketCreateException or BootstrapException on error BootstrapNode(const Ipv4 &address); ~BootstrapNode(); private: void acceptConnections(); void messageFromClient(std::shared_ptr peer, MessageType messageType, const void *data, const usize size); private: DirectConnections connections; std::unique_ptr socket; std::thread acceptConnectionsThread; PubsubKeyMap>> subscribedPeers; std::mutex subscribedPeersMutex; }; }