Skip to content

Commit

Permalink
add node name to user data
Browse files Browse the repository at this point in the history
  • Loading branch information
dirk-thomas committed Jan 26, 2018
1 parent d0707a0 commit a175c12
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions rmw_fastrtps_cpp/src/rmw_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,19 @@ rmw_create_node(
Domain::getDefaultParticipantAttributes(participantAttrs);

participantAttrs.rtps.builtin.domainId = static_cast<uint32_t>(domain_id);
// since the participant name is not part of the DDS spec
participantAttrs.rtps.setName(name);
// the node name is also set in the user_data
size_t name_length = strlen(name);
const char prefix[6] = "name=";
participantAttrs.rtps.userData.resize(name_length + sizeof(prefix));
memcpy(participantAttrs.rtps.userData.data(), prefix, sizeof(prefix) - 1);
{
for (size_t i = 0; i < name_length; ++i) {
participantAttrs.rtps.userData[sizeof(prefix) - 1 + i] = name[i];
}
participantAttrs.rtps.userData[sizeof(prefix) - 1 + name_length] = ';';
}

if (security_options->security_root_path) {
// if security_root_path provided, try to find the key and certificate files
Expand Down

0 comments on commit a175c12

Please sign in to comment.