template<typename T>
class RobotRaconteur::WireUnicastReceiver< T >
Receive the InValue from the most recent connection.
WireUnicastReceiver is used by services to receive a value from a single client. When a client sets its OutValue, this value is transmitted to the service using packets, and becomes the service's InValue for that connection. Service wires can have multiple active clients, so the service needs to choose which connection is "active". The WireUnicastReceiver selects the "most recent" connection, and returns that connection's InValue. Any existing connections are closed. WireUnicastReceiver should only be used with wires that are declared writeonly. It is recommended that object locks be used to protect from concurrent access when unicast receivers are used.
WireUnicastReceiver is initialized by the user, or by default implementation classes generated by RobotRaconteurGen (_default_impl). Default implementation classes will automatically instantiate unicast receivers for wires marked *writeonly. If default implementation classes are not used, the unicast receiver must be instantiated manually. It is recommended this be done using the IRRServiceObject interface in the overridden IRRServiceObject::RRServiceObjectInit() function. This function is called after the wires have been instantiated by the service.
The current InValue is received using GetInValue() or TryGetInValue(). The InValueChanged signal can be used to monitor for changes to the InValue.
Clients may also use PokeOutValue() or AsyncPokeOutValue() to update the unicast receiver's value.
- Template Parameters
-
template<typename T, typename U>
| void RobotRaconteur::WireUnicastReceiverBase< T, U >::SetInValueLifespan |
( |
int32_t | millis | ) |
|
|
inlineinherited |
Set the lifespan of InValue.
InValue may optionally have a finite lifespan specified in milliseconds. Once the lifespan after reception has expired, the InValue is cleared and becomes invalid. Attempts to access InValue will result in ValueNotSetException.
InValue lifespans may be used to avoid using a stale value received by the wire. If the lifespan is not set, the wire will continue to return the last received value, even if the value is old.
- Parameters
-
| millis | The lifespan in millisecond, or RR_VALUE_LIFESPAN_INFINITE for infinite lifespan |
template<typename T, typename U>
| bool RobotRaconteur::WireUnicastReceiverBase< T, U >::TryGetInValue |
( |
U & | value, |
|
|
TimeSpec & | ts, |
|
|
uint32_t & | ep ) |
|
inlineinherited |
Try getting the current InValue, returning true on success or false on failure.
Gets the current InValue, its timestamp, and the client endpoint ID. Returns true if value is valid, or false if value is invalid. Value will be invalid if no value has been received, or the value lifespan has expired.
- Parameters
-
| value | [out] The current InValue |
| ts | [out] The current InValue timestamp |
| ep | [out] The client endpoint ID of the InValue |
- Returns
- true value is valid
-
false value is invalid