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

[v5::service_client] Filter eventcalls by hostname in ecal_service_client_v5_impl #1932

Merged
merged 4 commits into from
Jan 23, 2025
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
44 changes: 32 additions & 12 deletions ecal/core/src/v5/service/ecal_service_client_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,17 @@ namespace eCAL
}
};

auto instances = m_service_client_impl->GetClientInstances();
bool success = false;
for (auto& instance : instances)
{
if (instance.GetClientID().host_name == m_host_name || m_host_name.empty())
{
success |= instance.CallWithCallback(method_name_, request_, timeout_, callback);
}
}
// Call the method using the new API
return m_service_client_impl->CallWithCallback(method_name_, request_, timeout_, callback);
return success;
}

bool CServiceClientImpl::Call(const std::string& method_name_, const std::string& request_, int timeout_, ServiceResponseVecT* service_response_vec_)
Expand All @@ -217,21 +226,23 @@ namespace eCAL

Logging::Log(Logging::log_level_debug1, "v5::CServiceClientImpl: Making a synchronous call with response collection to method: " + method_name_);

// Call the method using the new API
ServiceIDResponseVecT service_id_responses;
const bool success = m_service_client_impl->CallWithResponse(method_name_, request_, timeout_, service_id_responses);

// Convert the responses to the old format
service_response_vec_->clear();
for (const auto& service_id_response : service_id_responses)
auto instances = m_service_client_impl->GetClientInstances();
std::vector<std::pair<bool, SServiceIDResponse>> responses;
bool success = false;
for (auto& instance : instances)
{
// Filter responses based on host name if necessary
if (m_host_name.empty() || service_id_response.service_method_id.service_id.host_name == m_host_name)
if (instance.GetClientID().host_name == m_host_name || m_host_name.empty())
{
service_response_vec_->push_back(ConvertToServiceResponse(service_id_response));
responses.emplace_back(instance.CallWithResponse(method_name_, request_, timeout_));
success |= responses.back().first;
}
}

// Convert the responses to the old format
service_response_vec_->clear();
for (const auto& response : responses)
service_response_vec_->push_back(ConvertToServiceResponse(response.second));

Logging::Log(Logging::log_level_debug1, "v5::CServiceClientImpl: Call completed with success: " + std::to_string(success));
return success;
}
Expand Down Expand Up @@ -262,8 +273,17 @@ namespace eCAL
}
};

auto instances = m_service_client_impl->GetClientInstances();
bool success = false;
for (auto& instance : instances)
{
if (instance.GetClientID().host_name == m_host_name || m_host_name.empty())
{
success |= instance.CallWithCallbackAsync(method_name_, request_, callback);
}
}

// Call the method asynchronously using the new API
const bool success = m_service_client_impl->CallWithCallbackAsync(method_name_, request_, callback);
Logging::Log(Logging::log_level_debug1, "v5::CServiceClientImpl: Async call to method: " + method_name_ + " completed with success: " + std::to_string(success));
return success;
}
Expand Down
Loading