Skip to content

Commit

Permalink
Attach sequence number and publisher GID to serialized messages (#131)
Browse files Browse the repository at this point in the history
* Attach sequence number and publisher GID to serialized messages

Co-authored-by: Chris Lalancette <[email protected]>
  • Loading branch information
AlexDayCRL and clalancette authored Mar 20, 2024
1 parent 05d176b commit 740bfa9
Showing 1 changed file with 15 additions and 0 deletions.
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

0 comments on commit 740bfa9

Please sign in to comment.