diff options
| author | Dennis Brentjes <d.brentjes@gmail.com> | 2016-10-12 14:26:12 +0200 |
|---|---|---|
| committer | Dennis Brentjes <d.brentjes@gmail.com> | 2016-10-12 14:26:12 +0200 |
| commit | 7bca48bc5b5e37a3a8b0b23e57b88d069fa50589 (patch) | |
| tree | 47cd62512e631a064852015c65bb1965bc72414a /libcmix-network/client.cpp | |
| parent | 0fb433690c0ca5f9561fe9e2e973e2cd61b873ba (diff) | |
| download | cmix-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 'libcmix-network/client.cpp')
| -rw-r--r-- | libcmix-network/client.cpp | 36 |
1 files changed, 0 insertions, 36 deletions
diff --git a/libcmix-network/client.cpp b/libcmix-network/client.cpp index f693afa..755989b 100644 --- a/libcmix-network/client.cpp +++ b/libcmix-network/client.cpp @@ -2,13 +2,6 @@ #include "connect.hpp" -#include "logging.hpp" - -#include <boost/asio/placeholders.hpp> -#include <boost/bind.hpp> -#include <boost/asio/buffer.hpp> -#include <boost/array.hpp> - #include <iostream> using namespace boost::asio::ip; @@ -39,26 +32,6 @@ std::array<uint8_t, 4> Client::prepare_length_prefix(uint32_t length) return buf; } -void Client::send(std::string message) { - - auto length_buffer = prepare_length_prefix(message.size()); - - boost::array<boost::asio::const_buffer, 2> package = { - boost::asio::buffer(length_buffer.data(), length_buffer.size()), - boost::asio::buffer(message) - }; - - auto handler = [](boost::system::error_code const& ec, std::size_t bytes_transferred) { - if(ec) { - BOOST_LOG_TRIVIAL(fatal) << ec; - throw std::runtime_error("unable to send message"); - } - }; - - socket.async_send(package, 0, handler); - -} - std::vector<uint8_t> Client::received_bytes_to_vector(size_t read_bytes) { buffer->commit(read_bytes); @@ -103,15 +76,6 @@ void Client::handle_receive_size(Client::MessageHandler message_handler, error_c } } -void Client::receive(MessageHandler message_handler) { - using namespace boost::asio::placeholders; - - socket.async_receive( - buffer->prepare(4), - boost::bind(&Client::handle_receive_size, this, message_handler, error(), bytes_transferred()) - ); -} - void Client::close() { socket.close(); |
