Skip to content
This repository has been archived by the owner on Jun 21, 2023. It is now read-only.

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 e31ed1b commit 221769e
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions rmw_connext_shared_cpp/src/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,23 @@ create_node(
// This String_dup is not matched with a String_free because DDS appears to
// free this automatically.
participant_qos.participant_name.name = DDS::String_dup(name);
// since the participant name is not part of the DDS spec
// the node name is also set in the user_data
DDS_Long name_length = strlen(name);
const char prefix[6] = "name=";
bool success = participant_qos.user_data.value.length(name_length + sizeof(prefix));
if (!success) {
RMW_SET_ERROR_MSG("failed to resize participant user_data");
return NULL;
}
memcpy(participant_qos.user_data.value.get_contiguous_buffer(), prefix, sizeof(prefix) - 1);
{
for (DDS_Long i = 0; i < name_length; ++i) {
participant_qos.user_data.value[sizeof(prefix) - 1 + i] = name[i];
}
participant_qos.user_data.value[sizeof(prefix) - 1 + name_length] = ';';
}

// forces local traffic to be sent over loopback,
// even if a more efficient transport (such as shared memory) is installed
// (in which case traffic will be sent over both transports)
Expand Down

0 comments on commit 221769e

Please sign in to comment.