Skip to content

Commit b70ee52

Browse files
juanlu-rtifgarandalulivi
authored
ROUTING-1234: having the Service as Lib example in Recorder show the … (#697)
* ROUTING-1234: having the Service as Lib example in Recorder show the execute_command() API * Update examples/recording_service/service_as_lib/c++11/ServiceAsLibExample.cxx Co-authored-by: Fernando García Aranda <fernel@gmail.com> * ROUTING-1234: performing suggested linter changes * ROUTING-1234: Bring latest changes of the FindPackage * Change develop version file to latest --------- Co-authored-by: Fernando García Aranda <fernel@gmail.com> Co-authored-by: Luis Linan <luis@rti.com>
1 parent 2f13163 commit b70ee52

File tree

5 files changed

+23
-4
lines changed

5 files changed

+23
-4
lines changed

VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
7.3.0
1+
latest

examples/recording_service/service_admin/c++11/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ target_compile_features(Requester PRIVATE cxx_std_11)
4242
target_link_libraries(
4343
Requester
4444
RTIConnextDDS::messaging_cpp2_api
45+
RTIConnextDDS::service_admin_cpp2
4546
RTIConnextDDS::recording_service
4647
${CONNEXTDDS_EXTERNAL_LIBS}
4748
)

examples/recording_service/service_as_lib/c++11/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ target_include_directories(
6464
target_link_libraries(
6565
ServiceAsLibExample
6666
RTIConnextDDS::cpp2_api
67+
RTIConnextDDS::service_admin_cpp2
6768
RTIConnextDDS::recording_service
6869
${CONNEXTDDS_EXTERNAL_LIBS}
6970
)

examples/recording_service/service_as_lib/c++11/ServiceAsLibExample.cxx

+19-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
#include <rti/recording/Service.hpp>
1919
#include <rti/recording/ServiceProperty.hpp>
20-
20+
#include <rti/idlgen/ServiceAdmin.hpp>
2121

2222
void print_usage(const char *executable)
2323
{
@@ -109,7 +109,24 @@ int main(int argc, char *argv[])
109109
embedded_service.start();
110110
// Wait for 'running_seconds' seconds
111111
std::this_thread::sleep_for(std::chrono::seconds(running_seconds));
112-
embedded_service.stop();
112+
RTI::Service::Admin::CommandRequest request;
113+
request.action(RTI::Service::Admin::CommandActionKind::UPDATE_ACTION);
114+
request.resource_identifier(
115+
service_property.application_role()
116+
== rti::recording::ApplicationRoleKind::
117+
RECORD_APPLICATION
118+
? "/recording_services/service_as_lib/state"
119+
: "/replay_services/service_as_lib/state");
120+
request.string_body("STOPPED");
121+
RTI::Service::Admin::CommandReply reply =
122+
embedded_service.execute_command(request);
123+
if (reply.retcode()
124+
!= RTI::Service::Admin::CommandReplyRetcode::OK_RETCODE) {
125+
std::cerr << "Error stopping the service: " << reply.string_body()
126+
<< ", native error code = " << reply.native_retcode()
127+
<< std::endl;
128+
return EXIT_FAILURE;
129+
}
113130
} catch (const std::exception &ex) {
114131
std::cerr << "Exception: " << ex.what() << std::endl;
115132
return EXIT_FAILURE;

0 commit comments

Comments
 (0)