32 {
35 std::lock_guard<std::mutex> lock(mutex_);
36
37
38 auto channel_id =
common::Hash(sub->getAttributes().topic.getTopicName());
39 eprosima::fastrtps::SampleInfo_t m_info;
40 UnderlayMessage m;
41
42 RETURN_IF(!sub->takeNextData(
reinterpret_cast<void*
>(&m), &m_info));
43 RETURN_IF(m_info.sampleKind != eprosima::fastrtps::ALIVE);
44
45
46 char* ptr =
47 reinterpret_cast<char*>(&m_info.related_sample_identity.writer_guid());
48 Identity sender_id(false);
49 sender_id.set_data(ptr);
51
52 Identity spare_id(false);
53 spare_id.set_data(ptr +
ID_SIZE);
55
56 uint64_t seq_num =
57 ((int64_t)m_info.related_sample_identity.sequence_number().high) << 32 |
58 m_info.related_sample_identity.sequence_number().low;
60
61
62 std::shared_ptr<std::string> msg_str =
63 std::make_shared<std::string>(m.data());
64
66 uint64_t base_time = recv_time & 0xfffffff0000000;
67 int32_t send_time_low = m.timestamp();
68 uint64_t send_time = base_time | send_time_low;
69 int32_t msg_seq_num = m.seq();
70
73
74
75 callback_(channel_id, msg_str, msg_info_);
76}
uint64_t ToNanosecond() const
convert time to nanosecond.
static Time Now()
get the current time.
void set_msg_seq_num(int32_t msg_seq_num)
void set_seq_num(uint64_t seq_num)
void set_spare_id(const Identity &spare_id)
void set_send_time(uint64_t send_time)
void set_sender_id(const Identity &sender_id)
#define RETURN_IF_NULL(ptr)
#define RETURN_IF(condition)
std::size_t Hash(const std::string &key)
constexpr uint8_t ID_SIZE