aboutsummaryrefslogtreecommitdiff
path: root/node/prevnode.hpp
diff options
context:
space:
mode:
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();
+};
+