RTI Connext Traditional C++ API Version 7.5.0
|
Examples on how to use the request-reply API .
Examples on how to use the request-reply API .
Request-Reply code examples.
Requesters and Repliers provide a way to use the Request-Reply communication pattern on top of the DDS entities. An application uses a Requester to send requests to a Replier; another application using a Replier receives a request and can send one or more replies for that request. The Requester that sent the request (and only that one) will receive the reply (or replies).
DDS Types
RTI Connext uses DDS data types for sending and receiving requests and replies. Valid types are those generated by the rtiddsgen code generator, the DDS built-in types, and DynamicData
. Refer to the Core Libraries User's Manual and the following links for more information:
Set up
Requester: sending requests and receiving replies
Replier: receiving requests and sending replies
Error handling
rticonnextmsgcpp
library and include ndds/ndds_requestreply_cpp.h
.Basic Requester example using the String built-in type
This example is similar to Basic Requester example except it uses a SampleRef instance instead of a Sample instance.
Assuming the variables you want to use already exist:
You can use WriteSampleRef and SampleRef:
This next example shows how to implement a listener for a SimpleReplier using the std::string type
If you do not specify your own QoS parameters (in connext::RequesterParams and connext::ReplierParams), a connext::Requester and connext::Replier are created using a default configuration defined in the built-in profile DDS_PROFILE_PATTERN_RPC. You use this built-in profile as the base for your own profiles:
The example Creating a Requester with optional parameters shows how to create a connext::Requester using this profile.