23#include "fastdds/dds/subscriber/InstanceState.hpp"
25#include "fastdds/dds/topic/TopicDescription.hpp"
32namespace service_discovery {
36 : callback_(callback) {}
39 std::lock_guard<std::mutex> lck(mutex_);
44 eprosima::fastdds::dds::DataReader* reader) {
47 eprosima::fastdds::dds::SampleInfo m_info;
49 while (reader->take_next_sample(
reinterpret_cast<void*
>(&m), &m_info) ==
50 eprosima::fastrtps::types::ReturnCode_t::RETCODE_OK) {
51 if (m_info.valid_data) {
53 callback_(std::make_shared<std::string>(m.
data()), 0, msg_info_);
55 AERROR <<
"Remote writer for topic "
56 << reader->get_topicdescription()->get_name() <<
" is dead";
62 eprosima::fastdds::dds::DataReader* reader,
63 const eprosima::fastdds::dds::SubscriptionMatchedStatus& info) {
SubscriberListener(const transport::rtps::subsciber_callback &callback)
void on_subscription_matched(eprosima::fastdds::dds::DataReader *reader, const eprosima::fastdds::dds::SubscriptionMatchedStatus &info) override
void on_data_available(eprosima::fastdds::dds::DataReader *reader) override
virtual ~SubscriberListener()
This class represents the structure UnderlayMessage defined by the user in the IDL file.
void data(const std::string &_data)
This function copies the value in member data
#define RETURN_IF_NULL(ptr)
std::function< void(const std::shared_ptr< std::string > &msg_str, uint64_t channel_id, const MessageInfo &msg_info)> subsciber_callback