RTI Connext .Net APIs  Version 5.2.0
 All Classes Namespaces Functions Variables Enumerations Properties Groups Pages
RTI.Connext.RequestReply.Replier< TReq, TRep > Class Template Reference

Allows receiving requests and sending replies. More...

Inherits AlreadyDisposedHelper< Replier< TReq, TRep >>, and IDisposable.

Inherited by RTI.Connext.RequestReply.Replier< TReq, TRep >.ReplierDataReaderListener.

Public Member Functions

 Replier (ReplierParams< TReq, TRep > parameters)
 Creates a Replier with parameters.
 
 Replier (DomainParticipant participant, String serviceName, TypeSupport requestTypeSupport, TypeSupport replyTypeSupport)
 Creates a Replier with the minimum set of parameters.
 
void SendReply (TRep reply, SampleIdentity_t relatedRequestId)
 Sends a reply for a previous request.
 
void SendReply (WriteSample< TRep > reply, SampleIdentity_t relatedRequestId)
 Sends a reply for a previous request.
 
bool ReceiveRequest (Sample< TReq > request, Duration_t maxWait)
 Waits for a request and copies its contents into a Sample.
 
IList< Sample< TReq > > ReceiveRequests (IList< Sample< TReq >> replies, int maxCount, Duration_t maxWait)
 Waits for multiple requests and copies them into a list.
 
IList< Sample< TReq > > ReceiveRequests (IList< Sample< TReq >> replies, int minCount, int maxCount, Duration_t maxWait)
 Waits for multiple requests and copies them into a list.
 
LoanedSamples< TReq > ReceiveRequests (Duration_t maxWait)
 Waits for multiple requests and provides a loaned container to access them.
 
LoanedSamples< TReq > ReceiveRequests (int minCount, int maxCount, Duration_t maxWait)
 Waits for multiple requests and provides a loaned container to access them.
 
bool TakeRequest (Sample< TReq > request)
 Copies the contents of a request into a Sample.
 
LoanedSamples< TReq > TakeRequests ()
 Provides a loaned container to access the existing requests.
 
LoanedSamples< TReq > TakeRequests (int maxCount)
 Provides a loaned container to access the existing requests.
 
IList< Sample< TReq > > TakeRequests (IList< Sample< TReq >> requests, int maxCount)
 Copies existing requests into a list.
 
bool ReadRequest (Sample< TReq > request)
 Copies the contents of a request into a Sample.
 
LoanedSamples< TReq > ReadRequests ()
 Provides a loaned container to access the existing requests.
 
LoanedSamples< TReq > ReadRequests (int maxCount)
 Provides a loaned container to access the existing requests.
 
IList< Sample< TReq > > ReadRequests (IList< Sample< TReq >> requests, int maxCount)
 Copies existing requests into a list.
 
bool WaitForRequests (Duration_t maxWait)
 Waits for requests.
 
bool WaitForRequests (int minCount, Duration_t maxWait)
 Waits for requests.
 
WriteSample< TRep > CreateReplySample ()
 Creates a WriteSample for sending replies.
 
WriteSample< TRep > CreateReplySample (TRep data)
 Creates a WriteSample for sending replies.
 
Sample< TReq > CreateRequestSample ()
 Creates a Sample for receiving replies.
 

Properties

TypedDataWriter< TRep > ReplyDataWriter [get]
 Retrieves the underlying DDS::DataWriter.
 
TypedDataReader< TReq > RequestDataReader [get]
 Retrieves the underlying DDS::DataReader.
 

Detailed Description

Allows receiving requests and sending replies.

A Replier is an entity with two associated topics: a request topic and a reply topic. It can receive requests by subscribing to the request topic and can send replies to those requests by publishing the reply topic.

Valid types for these topics (TReq and TRep) are: those generated by the rtiddsgen code generator, the DDS built-in types, and DynamicData. See Creating a Replier.

A Replier has four main types of operations:

  • Waiting for requests to be received from the middleware
  • Getting those requests
  • Receiving requests (a convenience operation that is a combination of waiting and getting in a single operation)
  • Sending a reply for a previously received request (i.e., publishing a reply sample on the reply topic with special meta-data so that the orignal Requester can identify it)

For multi-reply scenarios in which a RTI::Connext::RequestReply::Replier<TReq,TRep> generates more than one reply for a request, the RTI::Connext::RequestReply::Replier<TReq,TRep> should mark all the intermediate replies (all but the last) using the ::DDS::SampleFlagBits::INTERMEDIATE_REPLY_SEQUENCE_SAMPLE flag in DDS::WriteParams_t::flag.

Much like a Requester, a Replier has an associated DDS::DomainParticipant, which can be shared with other Repliers or RTI Connext routines. All the other entities required for the request-reply interaction, including a DDS::DataWriter for writing replies and a DDS::DataReader for reading requests, are automatically created when the Replier is constructed.

Quality of Service for the underlying DataWriter and DataReader can be configured (see RTI::Connext::RequestReply::RequesterParams::SetQosProfile). By default, they are created with reliable quality of service. The exact default configuration is described here: Configuring Request-Reply QoS profiles

There are several ways to use a Replier:

Template Parameters
TReqThe data type for the request topic
TRepThe data type for the reply topic
See Also
RTI::Connext::RequestReply::Requester<TReq,TRep>
Request-Reply Examples
Basic Replier example
Type Constraints
TReq :class 
TReq :global 
TReq :DDS.ICopyable<TReq> 
TReq :new() 
TRep :class 
TRep :global 
TRep :DDS.ICopyable<TRep> 
TRep :new() 

Constructor & Destructor Documentation

RTI.Connext.RequestReply.Replier< TReq, TRep >.Replier ( ReplierParams< TReq, TRep >  parameters)
inline

Creates a Replier with parameters.

Parameters
paramsAll the parameters that configure this Replier
Exceptions
Oneof the Standard Return Codes
See Also
RTI::Connext::RequestReply::ReplierParams<TReq,TRep>
Creating a Replier
RTI.Connext.RequestReply.Replier< TReq, TRep >.Replier ( DomainParticipant  participant,
String  serviceName,
TypeSupport  requestTypeSupport,
TypeSupport  replyTypeSupport 
)
inline

Creates a Replier with the minimum set of parameters.

Parameters
participantThe DomainParticipant that this Replier uses to join a domain.
serviceNameThe service name. See RTI::Connext::RequestReply::ReplierParams<TReq,TRep>::SetServiceName
requestTypeSupportThe type support for type TReq
replyTypeSupportThe type support for type TReq
Exceptions
Oneof the Standard Return Codes

Member Function Documentation

void RTI.Connext.RequestReply.Replier< TReq, TRep >.SendReply ( TRep  reply,
SampleIdentity_t  relatedRequestId 
)
inline

Sends a reply for a previous request.

The related request identity can be retrieved from an existing request sample (RTI::Connext::Infrastructure::Sample<T>).

Parameters
replyThe reply to be sent.
relatedRequestIdThe identity of a previously received request
Exceptions
Oneof the Standard Return Codes
See Also
RTI::Connext::Infrastructure::Sample<T>::Identity
ReceiveRequest(Sample<TReq>,Duration_t)
ReceiveRequests(int,int,Duration_t)
TakeRequest(Sample<TReq>)
TakeRequests(int)
Basic Replier example
void RTI.Connext.RequestReply.Replier< TReq, TRep >.SendReply ( WriteSample< TRep >  reply,
SampleIdentity_t  relatedRequestId 
)
inline

Sends a reply for a previous request.

Allows you to set custom parameters for writing a reply.

Contrary to the RTI::Connext::RequestReply::Requester<TReq,TRep>, where retrieving the sample identity for correlation is common, on the Replier side using a WriteSample is only necessary when the default write parameters need to be overridden, and SendReply(TRep, SampleIdentity_t) may be used if that is not necessary.

One reason to override the default write parameters is a multi-reply scenario in which a RTI::Connext::RequestReply::Replier<TReq,TRep> generates more than one reply for a request. In this case, all the intermediate replies (all but the last) should be marked with the ::DDS::SampleFlagBits::INTERMEDIATE_REPLY_SEQUENCE_SAMPLE flag in DDS::WriteParams_t::flag within RTI::Connext::Infrastructure::WriteSample<T>::Info.

A RTI::Connext::RequestReply::Requester<TReq,TRep> can detect if a reply is the last reply of a sequence of replies by checking that the flag ::DDS::SampleFlagBits::INTERMEDIATE_REPLY_SEQUENCE_SAMPLE is not set in DDS::SampleInfo::flag within RTI::Connext::Infrastructure::Sample<T>::Info.

See Also
SendReply(TRep, SampleIdentity_t)
RTI::Connext::Infrastructure::WriteSample<T>
bool RTI.Connext.RequestReply.Replier< TReq, TRep >.ReceiveRequest ( Sample< TReq >  request,
Duration_t  maxWait 
)
inline
IList<Sample<TReq> > RTI.Connext.RequestReply.Replier< TReq, TRep >.ReceiveRequests ( IList< Sample< TReq >>  replies,
int  maxCount,
Duration_t  maxWait 
)
inline

Waits for multiple requests and copies them into a list.

Equivalent to ReceiveRequests(IList<Sample<TReq>>,int,int,Duration_t) with min_count = 0

See Also
RTI::Connext::Infrastructure::Sample<T>
ReceiveRequests(IList<Sample<TReq>>,int,Duration_t)
IList<Sample<TReq> > RTI.Connext.RequestReply.Replier< TReq, TRep >.ReceiveRequests ( IList< Sample< TReq >>  replies,
int  minCount,
int  maxCount,
Duration_t  maxWait 
)
inline
LoanedSamples<TReq> RTI.Connext.RequestReply.Replier< TReq, TRep >.ReceiveRequests ( Duration_t  maxWait)
inline

Waits for multiple requests and provides a loaned container to access them.

Equivalent to using ReceiveRequests(int,int,Duration_t) with min_count=1 and max_count=DDS::ResourceLimitsQosPolicy::LENGTH_UNLIMITED

See Also
RTI::Connext::Infrastructure::LoanedSamples<T>
ReceiveRequests(int,int,Duration_t)
LoanedSamples<TReq> RTI.Connext.RequestReply.Replier< TReq, TRep >.ReceiveRequests ( int  minCount,
int  maxCount,
Duration_t  maxWait 
)
inline

Waits for multiple requests and provides a loaned container to access them.

Equivalent to using WaitForRequests(int,Duration_t) and TakeRequests(int)

See Also
RTI::Connext::Infrastructure::LoanedSamples<T>
WaitForRequests(int,Duration_t)
TakeRequests(int)
bool RTI.Connext.RequestReply.Replier< TReq, TRep >.TakeRequest ( Sample< TReq >  request)
inline

Copies the contents of a request into a Sample.

See Also
RTI::Connext::RequestReply::Requester<TReq,TRep>::TakeReply(Sample<TRep>)
LoanedSamples<TReq> RTI.Connext.RequestReply.Replier< TReq, TRep >.TakeRequests ( )
inline
LoanedSamples<TReq> RTI.Connext.RequestReply.Replier< TReq, TRep >.TakeRequests ( int  maxCount)
inline

Provides a loaned container to access the existing requests.

See Also
RTI::Connext::RequestReply::Requester<TReq,TRep>::TakeReplies(int)
IList<Sample<TReq> > RTI.Connext.RequestReply.Replier< TReq, TRep >.TakeRequests ( IList< Sample< TReq >>  requests,
int  maxCount 
)
inline
bool RTI.Connext.RequestReply.Replier< TReq, TRep >.ReadRequest ( Sample< TReq >  request)
inline

Copies the contents of a request into a Sample.

This operation is equivalent to RTI::Connext::RequestReply::Replier<TReq,TRep>::TakeRequest(Sample<TReq>) except the request remains in the Replier and can be read or taken again.

LoanedSamples<TReq> RTI.Connext.RequestReply.Replier< TReq, TRep >.ReadRequests ( )
inline

Provides a loaned container to access the existing requests.

This operation is equivalent to RTI::Connext::RequestReply::Replier<TReq,TRep>::TakeRequests() except the requests remain in the Replier and can be read or taken again.

LoanedSamples<TReq> RTI.Connext.RequestReply.Replier< TReq, TRep >.ReadRequests ( int  maxCount)
inline

Provides a loaned container to access the existing requests.

This operation is equivalent to RTI::Connext::RequestReply::Replier<TReq,TRep>::TakeRequests(int) except the requests remain in the Replier and can be read or taken again.

IList<Sample<TReq> > RTI.Connext.RequestReply.Replier< TReq, TRep >.ReadRequests ( IList< Sample< TReq >>  requests,
int  maxCount 
)
inline

Copies existing requests into a list.

This operation is equivalent to RTI::Connext::RequestReply::Replier<TReq,TRep>::TakeRequests(IList<Sample<TReq>>,int) except the requests remain in the Replier and can be read or taken again.

bool RTI.Connext.RequestReply.Replier< TReq, TRep >.WaitForRequests ( Duration_t  maxWait)
inline

Waits for requests.

Equivalent to WaitForRequests(int,Duration_t) with min_count=1

See Also
WaitForRequests(int,Duration_t)
bool RTI.Connext.RequestReply.Replier< TReq, TRep >.WaitForRequests ( int  minCount,
Duration_t  maxWait 
)
inline

Waits for requests.

This operation waits for minCount requests to be available. It will wait up to maxWait .

This operation is similar to RTI::Connext::RequestReply::Requester<TReq,TRep>::WaitForReplies(int,Duration_t).

Parameters
minCountMinimum number of requests that need to be available for this operation to unblock.
maxWaitMaximum waiting time after which this operation unblocks regardless of how many requests are available.
Returns
true if at least minCount requests were available before maxWait elapsed, or false otherwise.
See Also
TakeRequests(int)
RTI::Connext::RequestReply::Requester<TReq,TRep>::WaitForReplies(int,Duration_t)
WriteSample<TRep> RTI.Connext.RequestReply.Replier< TReq, TRep >.CreateReplySample ( )
inline

Creates a WriteSample for sending replies.

Returns
A new WriteSample with data of type TReq initialized with default values and default write parameters.
See Also
RTI::Connext::Infrastructure::WriteSample<T>
SendReply(WriteSample<TRep>, SampleIdentity_t)
WriteSample<TRep> RTI.Connext.RequestReply.Replier< TReq, TRep >.CreateReplySample ( TRep  data)
inline

Creates a WriteSample for sending replies.

Returns
A new WriteSample with the specified data and default write parameters.
See Also
CreateReplySample()
Sample<TReq> RTI.Connext.RequestReply.Replier< TReq, TRep >.CreateRequestSample ( )
inline

Creates a Sample for receiving replies.

Returns
A new Sample with default data of type TReq and invalid SampleInfo.
See Also
RTI::Connext::Infrastructure::Sample<T>
ReceiveRequest(Sample<TReq>,Duration_t)
TakeRequest(Sample<TReq>)

Property Documentation

TypedDataWriter<TRep> RTI.Connext.RequestReply.Replier< TReq, TRep >.ReplyDataWriter
get
TypedDataReader<TReq> RTI.Connext.RequestReply.Replier< TReq, TRep >.RequestDataReader
get

RTI Connext .Net APIs Version 5.2.0 Copyright © Sun Jun 21 2015 Real-Time Innovations, Inc