Skip to content

Commit

Permalink
Refs #21295: Apply changes to new example
Browse files Browse the repository at this point in the history
Signed-off-by: elianalf <62831776+elianalf@users.noreply.github.com>
  • Loading branch information
elianalf committed Jul 17, 2024
1 parent 6bfa982 commit b6e5229
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 25 deletions.
17 changes: 9 additions & 8 deletions examples/cpp/request_reply/ClientApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,17 +143,18 @@ void ClientApp::stop()

void ClientApp::on_participant_discovery(
DomainParticipant* /* participant */,
rtps::ParticipantDiscoveryInfo&& info,
rtps::ParticipantDiscoveryStatus status,
const ParticipantBuiltinTopicData& info,
bool& should_be_ignored)
{
std::lock_guard<std::mutex> lock(mtx_);

should_be_ignored = false;

rtps::GuidPrefix_t remote_participant_guid_prefix = info.info.m_guid.guidPrefix;
std::string status_str = TypeConverter::to_string(info.status);
rtps::GuidPrefix_t remote_participant_guid_prefix = info.guid.guidPrefix;
std::string status_str = TypeConverter::to_string(status);

if (info.info.m_userData.data_vec().size() != 1)
if (info.user_data.data_vec().size() != 1)
{
should_be_ignored = true;
request_reply_debug("ClientApp", "Ignoring participant with invalid user data: "
Expand All @@ -162,7 +163,7 @@ void ClientApp::on_participant_discovery(

if (!should_be_ignored)
{
CLIParser::EntityKind entity_kind = static_cast<CLIParser::EntityKind>(info.info.m_userData.data_vec()[0]);
CLIParser::EntityKind entity_kind = static_cast<CLIParser::EntityKind>(info.user_data.data_vec()[0]);
if (CLIParser::EntityKind::SERVER != entity_kind)
{
should_be_ignored = true;
Expand All @@ -176,12 +177,12 @@ void ClientApp::on_participant_discovery(
{
std::string server_str = CLIParser::parse_entity_kind(CLIParser::EntityKind::SERVER);

if (info.status == rtps::ParticipantDiscoveryInfo::DISCOVERY_STATUS::DISCOVERED_PARTICIPANT)
if (status == rtps::ParticipantDiscoveryStatus::DISCOVERED_PARTICIPANT)
{
request_reply_debug("ClientApp", server_str << " " << status_str << ": " << remote_participant_guid_prefix);
}
else if (info.status == rtps::ParticipantDiscoveryInfo::DISCOVERY_STATUS::REMOVED_PARTICIPANT ||
info.status == rtps::ParticipantDiscoveryInfo::DISCOVERY_STATUS::DROPPED_PARTICIPANT)
else if (status == rtps::ParticipantDiscoveryStatus::REMOVED_PARTICIPANT ||
status == rtps::ParticipantDiscoveryStatus::DROPPED_PARTICIPANT)
{
request_reply_debug("ClientApp", server_str << " " << status_str << ": " << remote_participant_guid_prefix);
}
Expand Down
3 changes: 2 additions & 1 deletion examples/cpp/request_reply/ClientApp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ class ClientApp : public Application, public DomainParticipantListener
//! Participant discovery method
void on_participant_discovery(
DomainParticipant* participant,
rtps::ParticipantDiscoveryInfo&& info,
rtps::ParticipantDiscoveryStatus status,
const ParticipantBuiltinTopicData& info,
bool& should_be_ignored) override;

//! Publication matched method
Expand Down
17 changes: 9 additions & 8 deletions examples/cpp/request_reply/ServerApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,17 +130,18 @@ void ServerApp::stop()

void ServerApp::on_participant_discovery(
DomainParticipant* /* participant */,
rtps::ParticipantDiscoveryInfo&& info,
rtps::ParticipantDiscoveryStatus status,
const ParticipantBuiltinTopicData& info,
bool& should_be_ignored)
{
std::lock_guard<std::mutex> lock(mtx_);

should_be_ignored = false;

rtps::GuidPrefix_t remote_participant_guid_prefix = info.info.m_guid.guidPrefix;
std::string status_str = TypeConverter::to_string(info.status);
rtps::GuidPrefix_t remote_participant_guid_prefix = info.guid.guidPrefix;
std::string status_str = TypeConverter::to_string(status);

if (info.info.m_userData.data_vec().size() != 1)
if (info.user_data.data_vec().size() != 1)
{
should_be_ignored = true;
request_reply_debug("ServerApp", "Ignoring participant with invalid user data: "
Expand All @@ -149,7 +150,7 @@ void ServerApp::on_participant_discovery(

if (!should_be_ignored)
{
CLIParser::EntityKind entity_kind = static_cast<CLIParser::EntityKind>(info.info.m_userData.data_vec()[0]);
CLIParser::EntityKind entity_kind = static_cast<CLIParser::EntityKind>(info.user_data.data_vec()[0]);
if (CLIParser::EntityKind::CLIENT != entity_kind)
{
should_be_ignored = true;
Expand All @@ -163,12 +164,12 @@ void ServerApp::on_participant_discovery(
{
std::string client_str = CLIParser::parse_entity_kind(CLIParser::EntityKind::CLIENT);

if (info.status == rtps::ParticipantDiscoveryInfo::DISCOVERY_STATUS::DISCOVERED_PARTICIPANT)
if (status == rtps::ParticipantDiscoveryStatus::DISCOVERED_PARTICIPANT)
{
request_reply_debug("ServerApp", client_str << " " << status_str << ": " << remote_participant_guid_prefix);
}
else if (info.status == rtps::ParticipantDiscoveryInfo::DISCOVERY_STATUS::REMOVED_PARTICIPANT ||
info.status == rtps::ParticipantDiscoveryInfo::DISCOVERY_STATUS::DROPPED_PARTICIPANT)
else if (status == rtps::ParticipantDiscoveryStatus::REMOVED_PARTICIPANT ||
status == rtps::ParticipantDiscoveryStatus::DROPPED_PARTICIPANT)
{
client_matched_status_.match_reply_reader(remote_participant_guid_prefix, false);
client_matched_status_.match_request_writer(remote_participant_guid_prefix, false);
Expand Down
3 changes: 2 additions & 1 deletion examples/cpp/request_reply/ServerApp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ class ServerApp : public Application, public DomainParticipantListener
//! Participant discovery method
void on_participant_discovery(
DomainParticipant* participant,
rtps::ParticipantDiscoveryInfo&& info,
rtps::ParticipantDiscoveryStatus status,
const ParticipantBuiltinTopicData& info,
bool& should_be_ignored) override;

//! Publication matched method
Expand Down
12 changes: 6 additions & 6 deletions examples/cpp/request_reply/app_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,25 +225,25 @@ struct TypeConverter
}

static std::string to_string(
const rtps::ParticipantDiscoveryInfo::DISCOVERY_STATUS& info)
const rtps::ParticipantDiscoveryStatus& info)
{
std::string info_str = "Unknown";

switch (info)
{
case rtps::ParticipantDiscoveryInfo::DISCOVERY_STATUS::DISCOVERED_PARTICIPANT:
case rtps::ParticipantDiscoveryStatus::DISCOVERED_PARTICIPANT:
info_str = "discovered";
break;
case rtps::ParticipantDiscoveryInfo::DISCOVERY_STATUS::CHANGED_QOS_PARTICIPANT:
case rtps::ParticipantDiscoveryStatus::CHANGED_QOS_PARTICIPANT:
info_str = "changed QoS";
break;
case rtps::ParticipantDiscoveryInfo::DISCOVERY_STATUS::REMOVED_PARTICIPANT:
case rtps::ParticipantDiscoveryStatus::REMOVED_PARTICIPANT:
info_str = "removed";
break;
case rtps::ParticipantDiscoveryInfo::DISCOVERY_STATUS::DROPPED_PARTICIPANT:
case rtps::ParticipantDiscoveryStatus::DROPPED_PARTICIPANT:
info_str = "dropped";
break;
case rtps::ParticipantDiscoveryInfo::DISCOVERY_STATUS::IGNORED_PARTICIPANT:
case rtps::ParticipantDiscoveryStatus::IGNORED_PARTICIPANT:
info_str = "ignored";
break;
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#define FASTDDS_RTPS_PARTICIPANT__PARTICIPANTDISCOVERYINFO_HPP

#include <fastdds/fastdds_dll.hpp>

#include <fastdds/rtps/common/Guid.hpp>
namespace eprosima {
namespace fastdds {
namespace rtps {
Expand Down

0 comments on commit b6e5229

Please sign in to comment.