24 #ifndef GOBY_MIDDLEWARE_IO_LINE_BASED_TCP_SERVER_H
25 #define GOBY_MIDDLEWARE_IO_LINE_BASED_TCP_SERVER_H
32 #include <boost/asio/ip/tcp.hpp>
33 #include <boost/asio/read_until.hpp>
34 #include <boost/asio/streambuf.hpp>
35 #include <boost/system/error_code.hpp>
56 template <
typename TCPServerThreadType>
62 eol_matcher_(this->
cfg().end_of_line())
67 void async_read()
override
69 auto self(this->shared_from_this());
70 boost::asio::async_read_until(
72 [
this,
self](
const boost::system::error_code& ec, std::size_t bytes_transferred) {
73 if (!ec && bytes_transferred > 0)
75 auto io_msg = std::make_shared<goby::middleware::protobuf::IOData>();
76 auto& bytes = *io_msg->mutable_data();
77 bytes = std::string(bytes_transferred, 0);
78 std::istream is(&buffer_);
79 is.read(&bytes[0], bytes_transferred);
92 match_regex eol_matcher_;
93 boost::asio::streambuf buffer_;
102 typename Config = goby::middleware::protobuf::TCPServerConfig,
104 bool use_indexed_groups =
false>
107 Config, ThreadType, use_indexed_groups>
110 subscribe_layer, Config, ThreadType, use_indexed_groups>;
116 void start_session(boost::asio::ip::tcp::socket tcp_socket)
118 std::make_shared<TCPSessionLineBased<Base>>(std::move(tcp_socket), *
this)->start();
Class for grouping publications in the Goby middleware. Analogous to "topics" in ROS,...
Implements Thread for a three layer middleware setup ([ intervehicle [ interprocess [ interthread ] ]...
TCPServerThreadLineBased(const Config &config, int index=-1)
TCPSessionLineBased(boost::asio::ip::tcp::socket socket, TCPServerThreadType &server)
const TCPServerThreadType::ConfigType & cfg()
TCPSession(boost::asio::ip::tcp::socket socket, TCPServerThreadType &server)
void handle_read_error(const boost::system::error_code &ec)
boost::asio::ip::tcp::socket & mutable_socket()
void handle_read_success(std::size_t bytes_transferred, std::shared_ptr< goby::middleware::protobuf::IOData > io_msg)
detail namespace with internal helper functions
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.