File tree Expand file tree Collapse file tree
ddsenabler/examples/service Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3838CLIParser::example_config config;
3939bool service_discovered_ = false ;
4040uint32_t received_replies_ = 0 ;
41+ uint32_t sent_replies_ = 0 ;
4142std::vector<std::pair<uint64_t , std::string>> received_requests_;
4243std::mutex app_mutex_;
4344std::condition_variable app_cv_;
@@ -355,7 +356,7 @@ bool server_specific_logic(
355356 const std::string& request,
356357 uint64_t request_id)
357358{
358- std::this_thread::sleep_for (std::chrono::milliseconds (500 )); // Simulate processing time
359+ std::this_thread::sleep_for (std::chrono::milliseconds (200 )); // Simulate processing time
359360 std::string json = " {\" sum\" : 3}" ; // Example response, replace with actual logic
360361 if (!enabler->send_service_reply (service_name, json, request_id))
361362 {
@@ -403,8 +404,10 @@ bool server_routine(
403404 // Check if we have received the expected number of requests
404405 {
405406 std::lock_guard<std::mutex> lock (app_mutex_);
406- if (++received_replies_ >= expected_requests)
407+ if (++sent_replies_ >= expected_requests)
407408 {
409+ // Wait to ensure the last sent reply reaches destination
410+ std::this_thread::sleep_for (std::chrono::milliseconds (1000 ));
408411 return true ;
409412 }
410413 }
You can’t perform that action at this time.
0 commit comments