aboutsummaryrefslogtreecommitdiff
path: root/node/nextnode.hpp
diff options
context:
space:
mode:
authorDennis Brentjes <d.brentjes@gmail.com>2016-10-12 14:26:12 +0200
committerDennis Brentjes <d.brentjes@gmail.com>2016-10-12 14:26:12 +0200
commit7bca48bc5b5e37a3a8b0b23e57b88d069fa50589 (patch)
tree47cd62512e631a064852015c65bb1965bc72414a /node/nextnode.hpp
parent0fb433690c0ca5f9561fe9e2e973e2cd61b873ba (diff)
downloadcmix-7bca48bc5b5e37a3a8b0b23e57b88d069fa50589.tar.gz
cmix-7bca48bc5b5e37a3a8b0b23e57b88d069fa50589.tar.bz2
cmix-7bca48bc5b5e37a3a8b0b23e57b88d069fa50589.zip
Major network rewrite.
One generic class has been introduced to handle all connection types. Typedefs provide Sender Receiver and SenderReceiver types, which limit the functionality of the types. As to not accidentally communicate with the wrong node about things.
Diffstat (limited to 'node/nextnode.hpp')
-rw-r--r--node/nextnode.hpp66
1 files changed, 0 insertions, 66 deletions
diff --git a/node/nextnode.hpp b/node/nextnode.hpp
deleted file mode 100644
index c2e064c..0000000
--- a/node/nextnode.hpp
+++ /dev/null
@@ -1,66 +0,0 @@
-#pragma once
-
-#include "client.hpp"
-
-#include "cmix.pb.h"
-
-#include <boost/asio/ip/tcp.hpp>
-
-/*!
- * \file
- */
-
-/*!
- * MESSAGE_SETTER is a boilerplate macro that generates a setter function for our CMix
- * protobuf messages, This because there are seperate functions for each to type to use.
- * And there seems no way to solve this using templates.
- */
-#define MESSAGE_SETTER(TYPE, NAME) \
-inline void message_setter(cmix_proto::CMixMessage& m, cmix_proto::TYPE const& v) { \
- *m.mutable_##NAME() = v; \
-} \
-
-MESSAGE_SETTER(Initialization, initialization)
-MESSAGE_SETTER(ImANode, imanode)
-MESSAGE_SETTER(Bye, bye)
-
-#undef MESSAGE_SETTER
-
-/*!
- * \brief The NextNode class represents the next node in the network, will only be sent to.
- */
-class NextNode
-{
- Client client;
-public:
- /*!
- * \brief NextNode
- * \param socket an rvalue reference to the socket it takes ownership and uses to communicate with the next node in the network.
- */
- NextNode(boost::asio::ip::tcp::socket&& socket);
-
- /*!
- * \brief send
- * \param v The CMixMessage type we try to send and first have to wrap in a CMixMessage.
- */
- template <typename T>
- void send(T v) {
- cmix_proto::CMixMessage m;
- message_setter(m, v);
- client.send(m.SerializeAsString());
- }
-
- /*!
- * \brief async_connect
- * \param next_host The host of the next node.
- * \param next_port The port of the next node.
- * \param on_connect The callback to call when the connect was succesfull.
- */
- void async_connect(std::string next_host, std::string next_port, std::function<void()> on_connect);
-
- /*!
- * \brief close This function closes the underlying socket connection.
- */
- void close();
-};
-