|
Robot Raconteur Core C++ Library
|
Broadcaster to send packets to all connected clients. More...
#include <PipeMember.h>
Public Member Functions | |
| PipeBroadcaster () | |
| Construct a new PipeBroadcaster. | |
| void | Init (boost::shared_ptr< Pipe< T > > pipe, int32_t maximum_backlog=-1) |
| Initialize the PipeBroadcaster. | |
| void | SendPacket (T packet) |
| Send a packet to all connected pipe endpoint clients. | |
| void | AsyncSendPacket (T packet, boost::function< void()> handler) |
| Asynchronously send packet to all connected pipe endpoint clients. | |
| boost::shared_ptr< Pipe< T > > | GetPipe () |
| Get the associated pipe. | |
| boost::function< bool(const boost::shared_ptr< PipeBroadcasterBase > &, uint32_t, int32_t)> | GetPredicate () |
| Get the current predicate callback function. | |
| void | SetPredicate (boost::function< bool(const boost::shared_ptr< PipeBroadcasterBase > &, uint32_t, int32_t)> f) |
| Set the predicate callback function. | |
| int32_t | GetMaxBacklog () |
| Gets the currently configured maximum backlog. | |
| void | SetMaxBacklog (int32_t maximum_backlog) |
| Set the maximum backlog. | |
Broadcaster to send packets to all connected clients.
PipeBroadcaster is used by services to send packets to all connected client endpoints. It attaches to the pipe on the service side, and manages the lifecycle of connected endpoints. PipeBroadcaster should only be used with pipes that are declared readonly, since it has no provisions for receiving incoming packets from the client.
PipeBroadcaster is initialized by the user, or by default implementation classes generated by RobotRaconteurGen (_default_impl). Default implementation classes will automatically instantiate broadcasters for pipes 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 pipes have been instantiated by the service.
Use SendPacket() or AsyncSendPacket() to broadcast packets to all connected clients.
PipeBroadcaster provides flow control by optionally tracking how many packets are in flight to each client pipe endpoint. (This is accomplished using packet acks.) If a maximum backlog is specified, pipe endpoints exceeding this count will stop sending packets. Specify the maximum backlog using the Init() function or the SetMaxBacklog() function.
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 packet data type |
|
inline |
Construct a new PipeBroadcaster.
Must use boost::make_shared<PipeBroadcaster<T> >() to construct. Must call Init() after construction.
|
inline |
Asynchronously send packet to all connected pipe endpoint clients.
Asynchronous version of SendPacket()
| packet | The packet to send |
| handler | A handler function for when packet has been sent by all endpoints |
|
inherited |
Gets the currently configured maximum backlog.
|
inline |
Get the associated pipe.
|
inherited |
Get the current predicate callback function.
|
inline |
Initialize the PipeBroadcaster.
Initialize the PipeBroadcaster for use. Must be called after construction.
| pipe | The pipe to use for broadcasting. Must be a pipe from a service object. Specifying a client pipe will result in an exception. |
| maximum_backlog | The maximum number of packets in flight, or -1 for unlimited |
|
inline |
Send a packet to all connected pipe endpoint clients.
Blocks until packet has been sent by all endpoints
| packet | The packet to send |
|
inherited |
Set the maximum backlog.
PipeBroadcaster provides flow control by optionally tracking how many packets are in flight to each client pipe endpoint. (This is accomplished using packet acks.) If a maximum backlog is specified, pipe endpoints exceeding this count will stop sending packets.
| maximum_backlog | The maximum number of packets in flight, or -1 for unlimited |
|
inherited |
Set the predicate callback function.
A predicate is optionally used to regulate when packets are sent to clients. This is used by the BroadcastDownsampler to regulate update rates of packets sent to clients.
The predicate callback is invoked before the broadcaster sends a packet to an endpoint. If the predicate returns true, the packet will be sent. If it is false, the packet will not be sent to that endpoint. The predicate callback must have the following signature:
bool broadcaster_predicate(PipeBroadcasterBasePtr& broadcaster, uint32_t client_endpoint, int32_t
pipe_endpoint_index);
It receives the broadcaster, the client endpoint ID, and the pipe endpoint index. It returns true to send the packet, or false to not send the packet.
| f | The predicate callback function |