aboutsummaryrefslogtreecommitdiff
path: root/node/prevnode.hpp
diff options
context:
space:
mode:
authorDennis Brentjes <d.brentjes@gmail.com>2016-10-05 12:56:52 +0200
committerDennis Brentjes <d.brentjes@gmail.com>2016-10-05 14:12:28 +0200
commit88c5130eccd06e63ffca732626c0fb59426743a7 (patch)
treef9c7c4536bfa50057269c3636baedea3cb859ac1 /node/prevnode.hpp
parentedc3690d62890449df3ae4c14636019bce4833f1 (diff)
downloadcmix-88c5130eccd06e63ffca732626c0fb59426743a7.tar.gz
cmix-88c5130eccd06e63ffca732626c0fb59426743a7.tar.bz2
cmix-88c5130eccd06e63ffca732626c0fb59426743a7.zip
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.
Diffstat (limited to 'node/prevnode.hpp')
-rw-r--r--node/prevnode.hpp42
1 files changed, 42 insertions, 0 deletions
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 <boost/asio/ip/tcp.hpp>
+
+/*!
+ * \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<void(std::vector<uint8_t> const&)> receive_handler);
+
+ /*!
+ * \brief close This function closes the underlying socket connection.
+ */
+ void close();
+};
+