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>
53 class UDPPointToPointConfig;
71 bool use_indexed_groups =
false>
73 :
public UDPOneToManyThread<line_in_group, line_out_group, publish_layer, subscribe_layer,
74 goby::middleware::protobuf::UDPPointToPointConfig, ThreadType,
78 goby::middleware::protobuf::UDPPointToPointConfig, ThreadType,
88 boost::asio::ip::udp::resolver resolver(this->
mutable_io());
89 remote_endpoint_ = *resolver.resolve(
90 {this->cfg().remote_address(),
std::to_string(this->cfg().remote_port()),
91 boost::asio::ip::resolver_query_base::numeric_service});
94 this->interthread().template publish<line_in_group>(ready);
101 void async_write(std::shared_ptr<const goby::middleware::protobuf::IOData> io_msg)
override;
104 boost::asio::ip::udp::endpoint remote_endpoint_;
114 bool use_indexed_groups>
116 subscribe_layer, ThreadType, use_indexed_groups>::
117 async_write(std::shared_ptr<const goby::middleware::protobuf::IOData> io_msg)
119 this->mutable_socket().async_send_to(
120 boost::asio::buffer(io_msg->data()), remote_endpoint_,
121 [
this, io_msg](
const boost::system::error_code& ec, std::size_t bytes_transferred)
123 if (!ec && bytes_transferred > 0)
125 this->handle_write_success(bytes_transferred);
129 this->handle_write_error(ec);
Class for grouping publications in the Goby middleware. Analogous to "topics" in ROS,...
Implements Thread for a three layer middleware setup ([ intervehicle [ interprocess [ interthread ] ]...
~UDPPointToPointThread() override
UDPPointToPointThread(const goby::middleware::protobuf::UDPPointToPointConfig &config, int index=-1)
Constructs the thread.
boost::asio::io_context & mutable_io()
NLOHMANN_BASIC_JSON_TPL_DECLARATION std::string to_string(const NLOHMANN_BASIC_JSON_TPL &j)
user-defined to_string function for JSON values
extern ::PROTOBUF_NAMESPACE_ID::internal::ExtensionIdentifier< ::goby::acomms::protobuf::DriverConfig, ::PROTOBUF_NAMESPACE_ID::internal::MessageTypeTraits< ::goby::acomms::abc::protobuf::Config >, 11, false > config
The global namespace for the Goby project.