24#ifndef GOBY_MIDDLEWARE_IO_UDP_POINT_TO_POINT_H
25#define GOBY_MIDDLEWARE_IO_UDP_POINT_TO_POINT_H
31#include <boost/asio/buffer.hpp>
32#include <boost/asio/ip/udp.hpp>
33#include <boost/system/error_code.hpp>
54class UDPPointToPointConfig;
72 bool use_indexed_groups =
false>
74 :
public UDPOneToManyThread<line_in_group, line_out_group, publish_layer, subscribe_layer,
75 goby::middleware::protobuf::UDPPointToPointConfig, ThreadType,
87 :
Base(config, index, false)
89 boost::asio::ip::udp::resolver resolver(this->
mutable_io());
90 remote_endpoint_ = *resolver.resolve(
91 {this->cfg().remote_address(), std::to_string(this->cfg().remote_port()),
92 boost::asio::ip::resolver_query_base::numeric_service});
95 this->interthread().template publish<line_in_group>(ready);
102 void async_write(std::shared_ptr<const goby::middleware::protobuf::IOData> io_msg)
override;
105 boost::asio::ip::udp::endpoint remote_endpoint_;
115 bool use_indexed_groups>
117 subscribe_layer, ThreadType, use_indexed_groups>::
118 async_write(std::shared_ptr<const goby::middleware::protobuf::IOData> io_msg)
120 this->mutable_socket().async_send_to(
121 boost::asio::buffer(io_msg->data()), remote_endpoint_,
122 [
this, io_msg](
const boost::system::error_code& ec, std::size_t bytes_transferred)
124 if (!ec && bytes_transferred > 0)
126 this->handle_write_success(bytes_transferred);
130 this->handle_write_error(ec);
Class for grouping publications in the Goby middleware. Analogous to "topics" in ROS,...
~UDPPointToPointThread() override
UDPPointToPointThread(const goby::middleware::protobuf::UDPPointToPointConfig &config, int index=-1)
Constructs the thread.
boost::asio::io_context & mutable_io()
middleware::SimpleThread< Config, detail::InterProcessTag > SimpleThread
Zeromq-backed SimpleThread. Derives from middleware::SimpleThread using InterProcessTag.
The global namespace for the Goby project.