diff --git a/rtb/messaging/communicator.hpp b/rtb/messaging/communicator.hpp index c2f6c52..6c6ef71 100644 --- a/rtb/messaging/communicator.hpp +++ b/rtb/messaging/communicator.hpp @@ -28,6 +28,7 @@ #include #include #include +#include namespace vanilla { namespace messaging { @@ -192,7 +193,12 @@ class sender : ConnectionPolicy [](const boost::system::error_code&, std::size_t) { }); } - + + template Callback> + void send_async(Callback && callback) { + std::forward(callback)(socket_, to_endpoint_); + } + template void receive_async(Handler handler) { socket_.async_receive_from( @@ -273,6 +279,14 @@ class communicator { } return *this; } + + template Callback> + self_type & distribute(Callback && callback) { + if(distributor_) { + distributor_->send_async(std::forward(callback)); + } + return *this; + } template self_type & process(Handler handler) {