From 88c5130eccd06e63ffca732626c0fb59426743a7 Mon Sep 17 00:00:00 2001 From: Dennis Brentjes Date: Wed, 5 Oct 2016 12:56:52 +0200 Subject: Seperates Nodes and Clients for incoming connections. Created a PrevNode class to reflect the seperation. Made Client movable. Added 2 empty protobuf message that declare what each connecting client is, sent when connected to a node. --- node/prevnode.hpp | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 node/prevnode.hpp (limited to 'node/prevnode.hpp') diff --git a/node/prevnode.hpp b/node/prevnode.hpp new file mode 100644 index 0000000..6a6b431 --- /dev/null +++ b/node/prevnode.hpp @@ -0,0 +1,42 @@ +#pragma once + +#include "client.hpp" + +#include "cmix.pb.h" + +#include + +/*! + * \file + */ + +/*! + * \brief The PrevNode class represents the previous node in the network, will only be received from. + */ +class PrevNode +{ + Client client; +public: + /*! + * \brief PrevNode + * \param socket an rvalue reference to the socket it takes ownership and uses to communicate with the previous node in the network. + */ + PrevNode(Client&& socket); + + /*! + * \brief PrevNode move assignment operator. + */ + PrevNode& operator=(PrevNode&&) = default; + + /*! + * \brief receive Forwards a receive request to the client. + * \param receive_handler The function to call with the received data. + */ + void receive(std::function const&)> receive_handler); + + /*! + * \brief close This function closes the underlying socket connection. + */ + void close(); +}; + -- cgit v1.2.3-70-g09d2