diff --git a/ecal/core/include/ecal/ecal_client.h b/ecal/core/include/ecal/ecal_client.h index cfe1685c1c..aeec429acc 100644 --- a/ecal/core/include/ecal/ecal_client.h +++ b/ecal/core/include/ecal/ecal_client.h @@ -105,7 +105,7 @@ namespace eCAL * @return True if all calls were successful. **/ ECAL_API_EXPORTED_MEMBER - bool CallWithResponse(const std::string& method_name_, const std::string& request_, int timeout_, ServiceResponseVecT& service_response_vec_) const; + bool CallWithResponse(const std::string& method_name_, const std::string& request_, int timeout_, ServiceIDResponseVecT& service_response_vec_) const; /** * @brief Blocking call (with timeout) of a service method for all existing service instances, using callback diff --git a/ecal/core/include/ecal/ecal_client_instance.h b/ecal/core/include/ecal/ecal_client_instance.h index 2b278f908b..ecfc9b49ad 100644 --- a/ecal/core/include/ecal/ecal_client_instance.h +++ b/ecal/core/include/ecal/ecal_client_instance.h @@ -65,7 +65,7 @@ namespace eCAL * @return success state and service response **/ ECAL_API_EXPORTED_MEMBER - std::pair CallWithResponse(const std::string& method_name_, const std::string& request_, int timeout_ = -1); + std::pair CallWithResponse(const std::string& method_name_, const std::string& request_, int timeout_ = -1); /** * @brief Blocking call of a service method, using callback diff --git a/ecal/core/include/ecal/ecal_service_info.h b/ecal/core/include/ecal/ecal_service_info.h index 61b77e0b7d..8dbdee0a9a 100644 --- a/ecal/core/include/ecal/ecal_service_info.h +++ b/ecal/core/include/ecal/ecal_service_info.h @@ -35,7 +35,7 @@ namespace eCAL { /** - * @brief Service response struct containing the (responding) server informations and the response itself. + * @brief Service response struct containing the (responding) server informations and the response itself. (deprecated) **/ struct SServiceResponse { @@ -55,6 +55,19 @@ namespace eCAL }; using ServiceResponseVecT = std::vector; //!< vector of multiple service responses (deprecated) + /** + * @brief Service response struct containing the (responding) server informations and the response itself. + **/ + struct SServiceIDResponse + { + Registration::SServiceMethodId service_method_id; //!< service method information (service id (entity id, process id, host name), service name, method name) + std::string error_msg; //!< human readable error message + int ret_state = 0; //!< return state of the called service method + eCallState call_state = call_state_none; //!< call state (see eCallState) + std::string response; //!< service response + }; + using ServiceIDResponseVecT = std::vector; //!< vector of multiple service responses + /** * @brief Service method callback function type (low level server interface). * @@ -79,7 +92,7 @@ namespace eCAL * @param entity_id_ Unique service id (entity id, process id, host name, service name, method name) * @param service_response_ Service response struct containing the (responding) server informations and the response itself. **/ - using ResponseIDCallbackT = std::function; + using ResponseIDCallbackT = std::function; /** * @brief Map of . diff --git a/ecal/core/src/service/ecal_service_client.cpp b/ecal/core/src/service/ecal_service_client.cpp index 40803a9f9c..0dd218fa5d 100644 --- a/ecal/core/src/service/ecal_service_client.cpp +++ b/ecal/core/src/service/ecal_service_client.cpp @@ -77,13 +77,13 @@ namespace eCAL return instances; } - bool CServiceClient::CallWithResponse(const std::string& method_name_, const std::string& request_, int timeout_, ServiceResponseVecT& service_response_vec_) const + bool CServiceClient::CallWithResponse(const std::string& method_name_, const std::string& request_, int timeout_, ServiceIDResponseVecT& service_response_vec_) const { auto instances = GetClientInstances(); size_t num_instances = instances.size(); // vector to hold futures for the return values and responses - std::vector>> futures; + std::vector>> futures; futures.reserve(num_instances); // launch asynchronous calls for each instance @@ -106,9 +106,9 @@ namespace eCAL try { // explicitly unpack the pair - std::pair result = future.get(); + std::pair result = future.get(); bool success = result.first; - SServiceResponse response = result.second; + SServiceIDResponse response = result.second; // add response to the vector service_response_vec_.emplace_back(response); @@ -119,7 +119,7 @@ namespace eCAL catch (const std::exception& e) { // handle exceptions and add an error response - SServiceResponse error_response; + SServiceIDResponse error_response; error_response.error_msg = e.what(); error_response.call_state = call_state_failed; service_response_vec_.emplace_back(error_response); diff --git a/ecal/core/src/service/ecal_service_client_impl.cpp b/ecal/core/src/service/ecal_service_client_impl.cpp index 6bd435a265..6a81f75d5f 100644 --- a/ecal/core/src/service/ecal_service_client_impl.cpp +++ b/ecal/core/src/service/ecal_service_client_impl.cpp @@ -47,56 +47,18 @@ namespace return request_shared_ptr; } - // DeSerializes the response string into a service response - eCAL::SServiceResponse DeserializedResponse(const std::string& response_pb_) - { - eCAL::SServiceResponse service_reponse; - eCAL::Service::Response response; - if (eCAL::DeserializeFromBuffer(response_pb_.c_str(), response_pb_.size(), response)) - { - const auto& response_header = response.header; - service_reponse.host_name = response_header.hname; - service_reponse.service_name = response_header.sname; - service_reponse.service_id = response_header.sid; - service_reponse.method_name = response_header.mname; - service_reponse.error_msg = response_header.error; - service_reponse.ret_state = static_cast(response.ret_state); - - switch (response_header.state) - { - case eCAL::Service::eMethodCallState::executed: - service_reponse.call_state = call_state_executed; - break; - case eCAL::Service::eMethodCallState::failed: - service_reponse.call_state = call_state_failed; - break; - default: - break; - } - - service_reponse.response = std::string(response.response.data(), response.response.size()); - } - else - { - service_reponse.error_msg = "Could not parse server response"; - service_reponse.ret_state = 0; - service_reponse.call_state = eCallState::call_state_failed; - service_reponse.response = ""; - } - - return service_reponse; - } - - eCAL::SServiceResponse CreateErrorResponse(const eCAL::Registration::SEntityId& entity_id_, const std::string& service_name_, const std::string& method_name_, const std::string& error_message_) + eCAL::SServiceIDResponse CreateErrorResponse(const eCAL::Registration::SEntityId& entity_id_, const std::string& service_name_, const std::string& method_name_, const std::string& error_message_) { - eCAL::SServiceResponse error_response; - error_response.host_name = entity_id_.host_name; - error_response.service_name = service_name_; - error_response.service_id = entity_id_.entity_id; - error_response.method_name = method_name_; - error_response.error_msg = error_message_; - error_response.ret_state = 0; - error_response.call_state = call_state_failed; + eCAL::SServiceIDResponse error_response; + // service/method id + error_response.service_method_id.service_id = entity_id_; + error_response.service_method_id.service_name = service_name_; + error_response.service_method_id.method_name = method_name_; + + // error message, return state and call state + error_response.error_msg = error_message_; + error_response.ret_state = 0; + error_response.call_state = call_state_failed; return error_response; } @@ -200,7 +162,7 @@ namespace eCAL } // Calls a service method synchronously, blocking until a response is received or timeout occurs - std::pair CServiceClientImpl::CallWithCallback( + std::pair CServiceClientImpl::CallWithCallback( const Registration::SEntityId& entity_id_, const std::string& method_name_, const std::string& request_, int timeout_ms_, const ResponseIDCallbackT& response_callback_) { @@ -212,7 +174,7 @@ namespace eCAL if (!GetClientByEntity(entity_id_, client)) { eCAL::Logging::Log(log_level_warning, "CServiceClientImpl::CallWithCallback: Failed to find client for entity ID: " + entity_id_.entity_id); - return { false, SServiceResponse() }; + return { false, SServiceIDResponse() }; } auto response = CallMethodWithTimeout(entity_id_, client, method_name_, request_, std::chrono::milliseconds(timeout_ms_)); @@ -269,7 +231,7 @@ namespace eCAL auto response_data = PrepareInitialResponse(client, method_name_); // Create the response callback - auto response = [response_data, entity_id_, response_callback_](const eCAL::service::Error& error, const std::shared_ptr& response_) + auto response = [client, response_data, entity_id_, response_callback_](const eCAL::service::Error& error, const std::shared_ptr& response_) { const std::lock_guard lock(*response_data->mutex); if (!*response_data->block_modifying_response) @@ -288,7 +250,7 @@ namespace eCAL eCAL::Logging::Log(log_level_debug1, "CServiceClientImpl::CallWithCallbackAsync: Asynchronous call succeded"); #endif response_data->response->first = true; - response_data->response->second = DeserializedResponse(*response_); + response_data->response->second = DeserializedResponse(client, *response_); } } *response_data->finished = true; @@ -455,21 +417,21 @@ namespace eCAL } // Blocking call to a service with a specified timeout - std::pair CServiceClientImpl::CallMethodWithTimeout( + std::pair CServiceClientImpl::CallMethodWithTimeout( const Registration::SEntityId& entity_id_, SClient& client_, const std::string& method_name_, const std::string& request_, std::chrono::nanoseconds timeout_) { if (method_name_.empty()) - return { false, SServiceResponse() }; + return { false, SServiceIDResponse() }; // Serialize the request auto request_shared_ptr = SerializeRequest(method_name_, request_); if (!request_shared_ptr) - return { false, SServiceResponse() }; + return { false, SServiceIDResponse() }; // Prepare response data - auto response_data = PrepareInitialResponse(client_, method_name_); - auto response_callback = CreateResponseCallback(response_data); + auto response_data = PrepareInitialResponse(client_, method_name_); + auto response_callback = CreateResponseCallback(client_, response_data); // Send the service call const bool call_success = client_.client_session->async_call_service(request_shared_ptr, response_callback); @@ -559,21 +521,25 @@ namespace eCAL m_event_callback(service_id, callback_data); } - std::shared_ptr CServiceClientImpl::PrepareInitialResponse(SClient& client_, const std::string& method_name_) + std::shared_ptr CServiceClientImpl::PrepareInitialResponse(const SClient& client_, const std::string& method_name_) { auto data = std::make_shared(); data->response->first = false; - data->response->second.host_name = client_.service_attr.hname; - data->response->second.service_name = client_.service_attr.sname; - data->response->second.service_id = client_.service_attr.key; - data->response->second.method_name = method_name_; - data->response->second.call_state = eCallState::call_state_none; + + data->response->second.service_method_id.service_id.entity_id = client_.service_attr.sid; + data->response->second.service_method_id.service_id.process_id = client_.service_attr.pid; + data->response->second.service_method_id.service_id.host_name = client_.service_attr.hname; + + data->response->second.service_method_id.service_name = client_.service_attr.sname; + data->response->second.service_method_id.method_name = method_name_; + + data->response->second.call_state = eCallState::call_state_none; return data; } - eCAL::service::ClientResponseCallbackT CServiceClientImpl::CreateResponseCallback(const std::shared_ptr& response_data_) + eCAL::service::ClientResponseCallbackT CServiceClientImpl::CreateResponseCallback(const SClient& client_, const std::shared_ptr& response_data_) { - return [response_data_](const eCAL::service::Error& error, const std::shared_ptr& response_) + return [client_, response_data_](const eCAL::service::Error& error, const std::shared_ptr& response_) { const std::lock_guard lock(*response_data_->mutex); if (!*response_data_->block_modifying_response) @@ -588,11 +554,57 @@ namespace eCAL else { response_data_->response->first = true; - response_data_->response->second = DeserializedResponse(*response_); + response_data_->response->second = DeserializedResponse(client_, *response_); } } *response_data_->finished = true; response_data_->condition_variable->notify_all(); }; } + + // DeSerializes the response string into a service response + eCAL::SServiceIDResponse CServiceClientImpl::DeserializedResponse(const SClient& client_, const std::string& response_pb_) + { + eCAL::SServiceIDResponse service_reponse; + eCAL::Service::Response response; + if (eCAL::DeserializeFromBuffer(response_pb_.c_str(), response_pb_.size(), response)) + { + const auto& response_header = response.header; + // service/method id + service_reponse.service_method_id.service_id.entity_id = client_.service_attr.sid; + service_reponse.service_method_id.service_id.process_id = client_.service_attr.pid; + service_reponse.service_method_id.service_id.host_name = response_header.hname; + + // service and method name + service_reponse.service_method_id.service_name = response_header.sname; + service_reponse.service_method_id.method_name = response_header.mname; + + // error message and return state + service_reponse.error_msg = response_header.error; + service_reponse.ret_state = static_cast(response.ret_state); + + switch (response_header.state) + { + case eCAL::Service::eMethodCallState::executed: + service_reponse.call_state = call_state_executed; + break; + case eCAL::Service::eMethodCallState::failed: + service_reponse.call_state = call_state_failed; + break; + default: + break; + } + + service_reponse.response = std::string(response.response.data(), response.response.size()); + } + else + { + service_reponse.error_msg = "Could not parse server response"; + service_reponse.ret_state = 0; + service_reponse.call_state = eCallState::call_state_failed; + service_reponse.response = ""; + } + + return service_reponse; + } } diff --git a/ecal/core/src/service/ecal_service_client_impl.h b/ecal/core/src/service/ecal_service_client_impl.h index e6f25e1d7b..3943f2c29b 100644 --- a/ecal/core/src/service/ecal_service_client_impl.h +++ b/ecal/core/src/service/ecal_service_client_impl.h @@ -58,9 +58,9 @@ namespace eCAL // Retrieve service IDs of all matching services std::vector GetServiceIDs(); - // Blocking call to a specific service; returns response as pair + // Blocking call to a specific service; returns response as pair // if a callback is provided call the callback as well - std::pair CallWithCallback( + std::pair CallWithCallback( const Registration::SEntityId& entity_id_, const std::string& method_name_, const std::string& request_, int timeout_ms_, const ResponseIDCallbackT& response_callback_ = nullptr); @@ -107,7 +107,7 @@ namespace eCAL bool GetClientByEntity(const Registration::SEntityId& entity_id_, SClient& client_); // Blocking call to a specific service method with timeout - std::pair CallMethodWithTimeout(const Registration::SEntityId& entity_id_, SClient& client_, + std::pair CallMethodWithTimeout(const Registration::SEntityId& entity_id_, SClient& client_, const std::string& method_name_, const std::string& request_, std::chrono::nanoseconds timeout_); // Update the connection states for client sessions @@ -122,23 +122,25 @@ namespace eCAL // SResponseData struct for handling response callbacks struct SResponseData { - std::shared_ptr mutex; - std::shared_ptr condition_variable; - std::shared_ptr> response; - std::shared_ptr block_modifying_response; - std::shared_ptr finished; + std::shared_ptr mutex; + std::shared_ptr condition_variable; + std::shared_ptr> response; + std::shared_ptr block_modifying_response; + std::shared_ptr finished; SResponseData() : mutex(std::make_shared()), condition_variable(std::make_shared()), - response(std::make_shared>(false, SServiceResponse())), + response(std::make_shared>(false, SServiceIDResponse())), block_modifying_response(std::make_shared(false)), finished(std::make_shared(false)) {} }; - static std::shared_ptr PrepareInitialResponse(SClient& client_, const std::string& method_name_); - static eCAL::service::ClientResponseCallbackT CreateResponseCallback(const std::shared_ptr& response_data_); + static std::shared_ptr PrepareInitialResponse(const SClient& client_, const std::string& method_name_); + static eCAL::service::ClientResponseCallbackT CreateResponseCallback(const SClient& client_, const std::shared_ptr& response_data_); + + static SServiceIDResponse DeserializedResponse(const SClient& client_, const std::string& response_pb_); // Client version (incremented for protocol or functionality changes) static constexpr int m_client_version = 1; diff --git a/ecal/core/src/service/ecal_service_client_instance.cpp b/ecal/core/src/service/ecal_service_client_instance.cpp index 7bea328544..524159cd79 100644 --- a/ecal/core/src/service/ecal_service_client_instance.cpp +++ b/ecal/core/src/service/ecal_service_client_instance.cpp @@ -32,7 +32,7 @@ namespace eCAL assert(m_service_client_impl && "service_client_id_impl_ must not be null"); } - std::pair CClientInstance::CallWithResponse(const std::string& method_name_, const std::string& request_, int timeout_) + std::pair CClientInstance::CallWithResponse(const std::string& method_name_, const std::string& request_, int timeout_) { return m_service_client_impl->CallWithCallback(m_entity_id, method_name_, request_, timeout_); } diff --git a/ecal/core/src/service/ecal_service_client_v5_impl.cpp b/ecal/core/src/service/ecal_service_client_v5_impl.cpp index e4e4b05b01..d200f03453 100644 --- a/ecal/core/src/service/ecal_service_client_v5_impl.cpp +++ b/ecal/core/src/service/ecal_service_client_v5_impl.cpp @@ -24,6 +24,30 @@ #include "ecal_service_client_v5_impl.h" #include +namespace +{ + eCAL::SServiceResponse ConvertToServiceResponse(const eCAL::SServiceIDResponse& service_id_response) + { + eCAL::SServiceResponse service_response; + + // service/method id + service_response.host_name = service_id_response.service_method_id.service_id.host_name; + service_response.service_name = service_id_response.service_method_id.service_name; + service_response.service_id = std::to_string(service_id_response.service_method_id.service_id.entity_id); + service_response.method_name = service_id_response.service_method_id.method_name; + + // error message, return state and call state + service_response.error_msg = service_id_response.error_msg; + service_response.ret_state = service_id_response.ret_state; + service_response.call_state = service_id_response.call_state; + + // repsonse + service_response.response = service_id_response.response; + + return service_response; + } +} + namespace eCAL { namespace v5 @@ -152,18 +176,22 @@ namespace eCAL Logging::Log(log_level_debug1, "v5::CServiceClientImpl: Making a synchronous call to method: " + method_name_); // Wrap the response callback to filter by host name if necessary - ResponseIDCallbackT wrapped_callback = [this](const Registration::SEntityId& /*entity_id_*/, const struct SServiceResponse& service_response_) + ResponseIDCallbackT callback = [this](const Registration::SEntityId& /*entity_id_*/, const struct SServiceIDResponse& service_response_) { - if (m_host_name.empty() || service_response_.host_name == m_host_name) + if (m_host_name.empty() || service_response_.service_method_id.service_id.host_name == m_host_name) { Logging::Log(log_level_debug2, "v5::CServiceClientImpl: Response received for method call."); + + // Convert SServiceResponse to SServiceIDResponse + SServiceResponse service_response = ConvertToServiceResponse(service_response_); + // Call the stored response callback - m_response_callback(service_response_); + m_response_callback(service_response); } }; // Call the method using the new API - return m_service_client_impl->CallWithCallback(method_name_, request_, timeout_, wrapped_callback); + return m_service_client_impl->CallWithCallback(method_name_, request_, timeout_, callback); } bool CServiceClientImpl::Call(const std::string& method_name_, const std::string& request_, int timeout_, ServiceResponseVecT* service_response_vec_) @@ -182,25 +210,19 @@ namespace eCAL Logging::Log(log_level_debug1, "v5::CServiceClientImpl: Making a synchronous call with response collection to method: " + method_name_); // Call the method using the new API - ServiceResponseVecT all_responses; - bool success = m_service_client_impl->CallWithResponse(method_name_, request_, timeout_, all_responses); + ServiceIDResponseVecT service_id_responses; + bool success = m_service_client_impl->CallWithResponse(method_name_, request_, timeout_, service_id_responses); - // Filter responses based on host name if necessary - if (!m_host_name.empty()) + // Convert the responses to the old format + service_response_vec_->clear(); + for (const auto& service_id_response : service_id_responses) { - Logging::Log(log_level_debug2, "v5::CServiceClientImpl: Filtering responses based on host name: " + m_host_name); - for (const auto& response : all_responses) + // 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 (response.host_name == m_host_name) - { - service_response_vec_->push_back(response); - } + service_response_vec_->push_back(ConvertToServiceResponse(service_id_response)); } } - else - { - *service_response_vec_ = std::move(all_responses); - } Logging::Log(log_level_debug1, "v5::CServiceClientImpl: Call completed with success: " + std::to_string(success)); return success; @@ -222,13 +244,13 @@ namespace eCAL Logging::Log(log_level_debug1, "v5::CServiceClientImpl: Making an asynchronous call to method: " + method_name_); // Wrap the response callback to filter by host name if necessary - ResponseIDCallbackT wrapped_callback = [this](const Registration::SEntityId& /*entity_id_*/, const struct SServiceResponse& service_response_) + ResponseIDCallbackT wrapped_callback = [this](const Registration::SEntityId& /*entity_id_*/, const struct SServiceIDResponse& service_response_) { - if (m_host_name.empty() || service_response_.host_name == m_host_name) + if (m_host_name.empty() || service_response_.service_method_id.service_id.host_name == m_host_name) { Logging::Log(log_level_debug2, "v5::CServiceClientImpl: Response received for async method call."); // Call the stored response callback - m_response_callback(service_response_); + m_response_callback(ConvertToServiceResponse(service_response_)); } }; diff --git a/ecal/core/src/service/ecal_service_server_impl.cpp b/ecal/core/src/service/ecal_service_server_impl.cpp index 4d492e3e27..61770db0ec 100644 --- a/ecal/core/src/service/ecal_service_server_impl.cpp +++ b/ecal/core/src/service/ecal_service_server_impl.cpp @@ -348,7 +348,7 @@ namespace eCAL auto& response_header = response.header; response_header.hname = Process::GetHostName(); response_header.sname = m_service_name; - response_header.sid = m_service_id; + response_header.sid = std::to_string(m_service_id); // TODO: Service ID currently defined as string, should be integer as well // try to parse request Service::Request request; diff --git a/ecal/samples/cpp/services/minimal_client/src/minimal_client.cpp b/ecal/samples/cpp/services/minimal_client/src/minimal_client.cpp index 7a65d595fe..dc8127e8c8 100644 --- a/ecal/samples/cpp/services/minimal_client/src/minimal_client.cpp +++ b/ecal/samples/cpp/services/minimal_client/src/minimal_client.cpp @@ -33,18 +33,18 @@ int main() const eCAL::CServiceClient minimal_client("service1", { {"echo", eCAL::SServiceMethodInformation()} }); // callback for service response - auto service_response_callback = [](const eCAL::Registration::SEntityId& entity_id_, const eCAL::SServiceResponse& service_response_) { + auto service_response_callback = [](const eCAL::Registration::SEntityId& entity_id_, const eCAL::SServiceIDResponse& service_response_) { switch (service_response_.call_state) { // service successful executed case call_state_executed: { - std::cout << "Received response for method " << service_response_.method_name << " : " << service_response_.response << " from service id " << entity_id_.entity_id << " from host " << service_response_.host_name << std::endl; + std::cout << "Received response for method " << service_response_.service_method_id.method_name << " : " << service_response_.response << " from service id " << entity_id_.entity_id << " from host " << service_response_.service_method_id.service_id.host_name << std::endl; } break; // service execution failed case call_state_failed: - std::cout << "Received error for method " << service_response_.method_name << " : " << service_response_.error_msg << " from service id " << entity_id_.entity_id << " from host " << service_response_.host_name << std::endl; + std::cout << "Received error for method " << service_response_.service_method_id.method_name << " : " << service_response_.error_msg << " from service id " << entity_id_.entity_id << " from host " << service_response_.service_method_id.service_id.host_name << std::endl; break; default: break; diff --git a/ecal/tests/cpp/clientserver_test/src/clientserver_test.cpp b/ecal/tests/cpp/clientserver_test/src/clientserver_test.cpp index 0e4be483bc..3646a4d8b8 100644 --- a/ecal/tests/cpp/clientserver_test/src/clientserver_test.cpp +++ b/ecal/tests/cpp/clientserver_test/src/clientserver_test.cpp @@ -73,13 +73,13 @@ namespace #endif #if DO_LOGGING - void PrintResponse(const struct eCAL::SServiceResponse& service_response_) + void PrintResponse(const struct eCAL::SServiceIDResponse& service_response_) { std::cout << "------ RESPONSE ------" << std::endl; - std::cout << "Executed on host name : " << service_response_.host_name << std::endl; - std::cout << "Executed service name : " << service_response_.service_name << std::endl; - std::cout << "Executed method name : " << service_response_.method_name << std::endl; - std::cout << "Return value : " << service_response_.ret_state << std::endl; + std::cout << "Executed on host name : " << service_response_.service_method_id.service_id.host_name << std::endl; + std::cout << "Executed service name : " << service_response_.service_method_id.service_name << std::endl; + std::cout << "Executed method name : " << service_response_.service_method_id.method_name << std::endl; + std::cout << "Return value : " << service_response_.ret_state << std::endl; std::cout << "Execution state : "; switch (service_response_.call_state) { @@ -99,7 +99,7 @@ namespace std::cout << std::endl; } #else - void PrintResponse(const struct eCAL::SServiceResponse& /*service_response_*/) + void PrintResponse(const struct eCAL::SServiceIDResponse& /*service_response_*/) { } #endif @@ -285,7 +285,7 @@ TEST(core_cpp_clientserver, ClientServerBaseCallback) // response callback function std::atomic responses_executed(0); - auto response_callback = [&](const eCAL::Registration::SEntityId& /*entity_id_*/, const struct eCAL::SServiceResponse& service_response_) + auto response_callback = [&](const eCAL::Registration::SEntityId& /*entity_id_*/, const struct eCAL::SServiceIDResponse& service_response_) { PrintResponse(service_response_); responses_executed++; @@ -403,7 +403,7 @@ TEST(core_cpp_clientserver, ClientServerBaseCallbackTimeout) // response callback function std::atomic responses_executed(0); - auto response_callback = [&](const eCAL::Registration::SEntityId& /*entity_id_*/, const struct eCAL::SServiceResponse& service_response_) + auto response_callback = [&](const eCAL::Registration::SEntityId& /*entity_id_*/, const struct eCAL::SServiceIDResponse& service_response_) { PrintResponse(service_response_); responses_executed++; @@ -538,7 +538,7 @@ TEST(core_cpp_clientserver, ClientServerBaseAsyncCallback) // response callback function std::atomic responses_executed(0); - auto response_callback = [&](const eCAL::Registration::SEntityId& /*entity_id_*/, const struct eCAL::SServiceResponse& service_response_) + auto response_callback = [&](const eCAL::Registration::SEntityId& /*entity_id_*/, const struct eCAL::SServiceIDResponse& service_response_) { PrintResponse(service_response_); responses_executed++; @@ -613,7 +613,7 @@ TEST(core_cpp_clientserver, ClientServerBaseAsync) // response callback function atomic_signalable num_client_response_callbacks_finished(0); - auto response_callback = [&](const eCAL::Registration::SEntityId& /*entity_id_*/, const struct eCAL::SServiceResponse& service_response_) + auto response_callback = [&](const eCAL::Registration::SEntityId& /*entity_id_*/, const struct eCAL::SServiceIDResponse& service_response_) { PrintResponse(service_response_); num_client_response_callbacks_finished++; @@ -733,7 +733,7 @@ TEST(core_cpp_clientserver, ClientServerBaseBlocking) // call service std::atomic methods_called(0); std::atomic responses_executed(0); - eCAL::ServiceResponseVecT service_response_vec; + eCAL::ServiceIDResponseVecT service_response_vec; for (auto i = 0; i < calls; ++i) { // call methods @@ -822,12 +822,12 @@ TEST(core_cpp_clientserver, NestedRPCCall) std::atomic methods_called(0); std::atomic responses_executed(0); bool success(true); - auto response_callback2 = [&](const eCAL::Registration::SEntityId& /*entity_id_*/, const struct eCAL::SServiceResponse& service_response_) + auto response_callback2 = [&](const eCAL::Registration::SEntityId& /*entity_id_*/, const struct eCAL::SServiceIDResponse& service_response_) { PrintResponse(service_response_); responses_executed++; }; - auto response_callback1 = [&](const eCAL::Registration::SEntityId& /*entity_id_*/, const struct eCAL::SServiceResponse& service_response_) + auto response_callback1 = [&](const eCAL::Registration::SEntityId& /*entity_id_*/, const struct eCAL::SServiceIDResponse& service_response_) { PrintResponse(service_response_); success &= client2.CallWithCallback("foo::method2", "my request for method 2", -1, response_callback2); diff --git a/serialization/protobuf/samples/services/ping_client_dyn/src/ping_client_dyn.cpp b/serialization/protobuf/samples/services/ping_client_dyn/src/ping_client_dyn.cpp index fac1277602..720a13e98f 100644 --- a/serialization/protobuf/samples/services/ping_client_dyn/src/ping_client_dyn.cpp +++ b/serialization/protobuf/samples/services/ping_client_dyn/src/ping_client_dyn.cpp @@ -95,7 +95,7 @@ int main() if (!ping_request.empty()) { // call Ping service method - eCAL::ServiceResponseVecT service_response_vec; + eCAL::ServiceIDResponseVecT service_response_vec; if (ping_client.CallWithResponse("Ping", ping_request, -1, service_response_vec)) { std::cout << '\n' << "PingService::Ping method called with message (JSON) : " << req_json << '\n'; @@ -108,12 +108,12 @@ int main() case call_state_executed: { const std::string resp_json = GetJSONFromSerialzedMessage(resp_msg.get(), service_response.response); - std::cout << "Received response PingService / Ping (JSON) : " << resp_json << " from host " << service_response.host_name << '\n'; + std::cout << "Received response PingService / Ping (JSON) : " << resp_json << " from host " << service_response.service_method_id.service_id.host_name << '\n'; } break; // service execution failed case call_state_failed: - std::cout << "Received error PingService / Ping : " << service_response.error_msg << " from host " << service_response.host_name << '\n'; + std::cout << "Received error PingService / Ping : " << service_response.error_msg << " from host " << service_response.service_method_id.service_id.host_name << '\n'; break; default: break;