|
Robot Raconteur Core C++ Library
|
Broadcaster to send values to all connected clients. More...
#include <WireMember.h>
Public Member Functions | |
| WireBroadcaster () | |
| Construct a new WireBroadcaster. | |
| void | Init (boost::shared_ptr< Wire< T > > wire) |
| Initialize the WireBroadcaster. | |
| void | SetOutValue (T value) |
| Set the OutValue for all connections. | |
| boost::function< bool(boost::shared_ptr< WireBroadcasterBase > &, uint32_t)> | GetPredicate () |
| Get the current predicate callback function. | |
| void | SetPredicate (boost::function< bool(const boost::shared_ptr< WireBroadcasterBase > &, uint32_t)> f) |
| Set the predicate callback function. | |
| int32_t | GetOutValueLifespan () |
| Get the lifespan of OutValue. | |
| void | SetOutValueLifespan (int32_t millis) |
| Set the lifespan of OutValue. | |
Broadcaster to send values to all connected clients.
WireBroadcaster is used by services to send values to all connected client endpoints. It attaches to the wire on the service side, and manages the lifecycle of connections. WireBroadcaster should only we used with wires that are declared readonly, since it has no provisions for receiving incoming values from clients.
WireBroadcaster is initialized by the user, or by default implementation classes generated by RobotRaconteurGen (_default_impl). Default implementation classes will automatically instantiate broadcasters for wires marked *readonly. If default implementation classes are not used, the broadcaster 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.
Use SetOutValue() to broadcast values to all connected clients.
The rate that packets are sent can be regulated using a callback function configured with the SetPredicate() function, or using the BroadcastDownsampler class.
| T | The value data type |
|
inline |
Construct a new WireBroadcaster.
Must use boost::make_shared<WireBroadcaster<T> > to construct. Must call Init() after construction.
|
inherited |
Get the lifespan of OutValue.
OutValue may optionally have a finite lifespan specified in milliseconds. Once the lifespan after sending has expired, the OutValue is cleared, and becomes invalid. Attempts to access OutValue will result in a ValueNotSetException.
|
inherited |
Get the current predicate callback function.
|
inline |
Initialize the WireBroadcaster.
Initialize the WireBroadcaster for use. Must be called after construction.
| wire | The wire to use for broadcasting. Must be a wire from a service object. Specifying a client wire will result in an exception. |
|
inline |
Set the OutValue for all connections.
Sets the OutValue for all connections. This will transmit the value to all connected clients using packets. The value will become the clients' InValue.
The value will be returned when clients call Wire::PeekInValue() or Wire::AsyncPeekInValue()
| value | The new OutValue |
|
inherited |
Set the lifespan of OutValue.
OutValue may optionally have a finite lifespan specified in milliseconds. Once the lifespan after sending has expired, the OutValue is cleared and becomes invalid. Attempts to access OutValue will result in ValueNotSetException.
OutValue lifespans may be used to avoid using a stale value sent by the wire. If the lifespan is not set, the wire will continue to return the last sent value, even if the value is old.
| millis | The lifespan in millisecond, or RR_VALUE_LIFESPAN_INFINITE for infinite lifespan |
|
inherited |
Set the predicate callback function.
A predicate is optionally used to regulate when values are sent to clients. This is used by the BroadcastDownsampler to regulate update rates of values sent to clients.
The predicate callback is invoked before the broadcaster sets the OutValue of a connection. If the predicate returns true, the OutValue packet will be sent. If it is false, the OutValue packet will not be sent to that endpoint. The predicate callback must have the following signature:
bool broadcaster_predicate(WireBroadcasterBasePtr& broadcaster, uint32_t client_endpoint);
It receives the broadcaster and the client endpoint ID. It returns true to send the OutValue packet, or false to not send the OutValue packet.
| f | The predicate callback function |