#pragma once #include "client.hpp" #include "logging.hpp" #include template class ProtobufClient : private Client { public: using Client::Client; using Client::operator=; using Client::async_connect; template void async_send(V value, F on_sent) { typename T::proto_type m = T()(value); Client::async_send(m.SerializeAsString(), on_sent); } template void async_send(V value) { async_send(value, []{}); } template void async_receive(F message_handler) { auto f = [message_handler](std::vector const& buffer) { typename T::proto_type message; if(!message.ParseFromArray(buffer.data(), buffer.size())) { BOOST_LOG_TRIVIAL(error) << "Received something which was not a CMixMessage"; throw std::runtime_error("Network communication was disrupted in a unrecoverable way."); } message_handler(message); }; Client::async_receive(f); } using Client::close; using Client::on_done; using Client::is_open; };