Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attach sequence number and publisher GID to serialized messages #131

Merged
merged 2 commits into from
Mar 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions rmw_zenoh_cpp/src/rmw_zenoh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1044,13 +1044,28 @@ rmw_publish_serialized_message(
return RMW_RET_ERROR;
}

uint64_t sequence_number = publisher_data->get_next_sequence_number();

z_owned_bytes_map_t map =
create_map_and_set_sequence_num(sequence_number, publisher_data->pub_gid);

if (!z_check(map)) {
// create_map_and_set_sequence_num already set the error
return RMW_RET_ERROR;
}
auto free_attachment_map = rcpputils::make_scope_exit(
[&map]() {
z_bytes_map_drop(z_move(map));
});

const size_t data_length = ser.getSerializedDataLength();

// The encoding is simply forwarded and is useful when key expressions in the
// session use different encoding formats. In our case, all key expressions
// will be encoded with CDR so it does not really matter.
z_publisher_put_options_t options = z_publisher_put_options_default();
options.encoding = z_encoding(Z_ENCODING_PREFIX_EMPTY, NULL);
options.attachment = z_bytes_map_as_attachment(&map);
// Returns 0 if success.
int8_t ret = z_publisher_put(
z_loan(publisher_data->pub),
Expand Down
Loading