Skip to content

Commit

Permalink
Added subscribers
Browse files Browse the repository at this point in the history
Signed-off-by: Alejandro Hernández Cordero <[email protected]>
  • Loading branch information
ahcorde committed Nov 21, 2024
1 parent cf03d9c commit 45046ec
Show file tree
Hide file tree
Showing 6 changed files with 230 additions and 171 deletions.
25 changes: 25 additions & 0 deletions rmw_zenoh_cpp/src/detail/attachment_helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,31 @@ zenoh::Bytes AttachementData::serialize_to_zbytes()
return std::move(serializer).finish();
}

AttachementData::AttachementData(const zenoh::Bytes & attachment)
{
zenoh::ext::Deserializer deserializer(std::move(attachment));
const auto sequence_number_str = deserializer.deserialize<std::string>();
if (sequence_number_str != "sequence_number")
{
throw std::runtime_error("sequence_number is not found in the attachment.");
}
this->sequence_number = deserializer.deserialize<int64_t>();

const auto source_timestamp_str = deserializer.deserialize<std::string>();
if (source_timestamp_str != "source_timestamp")
{
throw std::runtime_error("source_timestamp is not found in the attachment.");
}
this->source_timestamp = deserializer.deserialize<int64_t>();

const auto source_gid_str = deserializer.deserialize<std::string>();
if (source_gid_str != "source_gid")
{
throw std::runtime_error("source_gid is not found in the attachment.");
}
this->source_gid = deserializer.deserialize<std::vector<uint8_t>>();
}

attachement_data_t::attachement_data_t(
const int64_t _sequence_number,
const int64_t _source_timestamp,
Expand Down
2 changes: 1 addition & 1 deletion rmw_zenoh_cpp/src/detail/attachment_helpers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class AttachementData final
const int64_t _source_timestamp,
const uint8_t _source_gid[RMW_GID_STORAGE_SIZE]);

// explicit AttachementData(const zenoh::Bytes & bytes);
explicit AttachementData(const zenoh::Bytes & bytes);
explicit AttachementData(AttachementData && data);

int64_t sequence_number;
Expand Down
Loading

0 comments on commit 45046ec

Please sign in to comment.