Skip to content

Commit

Permalink
Update communicator.hpp
Browse files Browse the repository at this point in the history
  • Loading branch information
cxx24 authored Aug 1, 2024
1 parent 495047d commit 57054f0
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions rtb/messaging/communicator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ class sender : ConnectionPolicy
to_endpoint_{ConnectionPolicy::sender_endpoint(socket_, port , std::forward<IPAddress>(addresses)...)}
{}

template<vanilla::common::boost_serializable_v Serializable>
template<typename Serializable>
void send_async( Serializable && data) {
out_data_ = serialize(std::forward<Serializable>(data));
socket_.async_send_to(
Expand All @@ -194,12 +194,9 @@ class sender : ConnectionPolicy
});
}

template <vanilla::common::const_buffer_sequence T>
void send_async(T const& buffers) {
socket_.async_send_to(
buffers, to_endpoint_,
[](boost::system::error_code const&, std::size_t) {
});
template <std::invocable<boost::asio::ip::udp::socket &, boost::asio::ip::udp::endpoint const&> Callback>
void send_async(Callback && callback) {
std::forward<Callback>(callback)(socket_, to_endpoint_);
}

template<typename Handler>
Expand Down Expand Up @@ -268,7 +265,7 @@ class communicator {
}


template<vanilla::common::boost_serializable_v Serializable>
template<typename Serializable>
self_type & distribute(Serializable && data) {
if(distributor_) {
distributor_->send_async(std::forward<Serializable>(data));
Expand All @@ -283,10 +280,10 @@ class communicator {
return *this;
}

template <vanilla::common::const_buffer_sequence T>
self_type & distribute(T const& buffers) {
template <std::invocable<boost::asio::ip::udp::socket &, boost::asio::ip::udp::endpoint const&> Callback>
self_type & distribute(Callback && callback) {
if(distributor_) {
distributor_->send_async(buffers);
distributor_->send_async(std::forward<Callback>(callback));
}
return *this;
}
Expand Down

0 comments on commit 57054f0

Please sign in to comment.