|
Robot Raconteur Core C++ Library
|
Subscription for pipe members that aggregates incoming packets from client pipe endpoints. More...
#include <Subscription.h>
Public Member Functions | |
| T | ReceivePacket () |
| Dequeue a packet from the receive queue. | |
| bool | TryReceivePacket (T &packet) |
| Try dequeuing a packet from the receive queue. | |
| bool | TryReceivePacketWait (T &packet, int32_t timeout=RR_TIMEOUT_INFINITE, bool peek=false, boost::shared_ptr< PipeEndpoint< T > > *ep=NULL) |
| Try dequeuing a packet from the receive queue, optionally waiting or peeking the packet. | |
| void | AsyncSendPacketAll (const T &packet) |
| Sends a packet to all connected pipe endpoints. | |
| event_connection | AddPipePacketReceivedListener (boost::function< void(const boost::shared_ptr< PipeSubscription< T > > &)> f) |
| Adds a pipe packet received event listener function. | |
| size_t | Available () |
| Get the number of packets available to receive. | |
| size_t | GetActivePipeEndpointCount () |
| Get the number of pipe endpoints currently connected. | |
| bool | GetIgnoreReceived () |
| Get if incoming packets are currently being ignored. | |
| void | SetIgnoreReceived (bool ignore) |
| Set if incoming packets should be ignored. | |
| void | Close () |
| Closes the pipe subscription. | |
Subscription for pipe members that aggregates incoming packets from client pipe endpoints.
Pipe subscriptions are created using the ServiceSubscription::SubscribePipe() function. This function takes the the type of the pipe packets, the name of the pipe member, and an optional service path of the service object that owns the pipe member.
Pipe subscriptions collect all incoming packets from connect pipe endpoints. When a client connects, the pipe subscription will automatically connect a pipe endpoint the pipe endpoint specified when the PipeSubscription was created using ServiceSubscription::SubscribePipe(). The packets received from each of the collected pipes are collected and placed into a common receive queue. This queue is read using ReceivePacket(), TryReceivePacket(), or TryReceivePacketWait(). The number of packets available to receive can be checked using Available().
Pipe subscriptions can also be used to send packets to all connected pipe endpoints. This is done with the AsyncSendPacketAll() function. This function behaves somewhat like a "reverse broadcaster", sending the packets to all connected services.
If the pipe subscription is being used to send packets but not receive them, the SetIgnoreInValue() should be set to true to prevent packets from queueing.
| T | The type of the pipe packets |
|
inline |
Adds a pipe packet received event listener function.
Add a listener function that is called when the pipe subscription receives a packet. The callback should have the signature:
void cb(PipeSubscriptionPtr<T> pipe_subscription)
The callback function does not include the received packets as an argument. The callback must call one of the ReceivePacket() functions to dequeue the packets.
| f | The callback function |
|
inline |
Sends a packet to all connected pipe endpoints.
Calls AsyncSendPacket() on all connected pipe endpoints with the specified value. Returns immediately, not waiting for transmission to complete.
| packet | The packet to send |
|
inherited |
Get the number of packets available to receive.
Use ReceivePacket(), TryReceivePacket(), or TryReceivePacketWait() to receive the packet
|
inherited |
Closes the pipe subscription.
Pipe subscriptions are automatically closed when the parent ServiceSubscription is closed or when the node is shut down.
|
inherited |
Get the number of pipe endpoints currently connected.
|
inherited |
Get if incoming packets are currently being ignored.
|
inline |
Dequeue a packet from the receive queue.
If the receive queue is empty, an InvalidOperationException() is thrown
|
inherited |
Set if incoming packets should be ignored.
See PipeEndpoint::SetIgnoreReceived();
If true, receivedpackets will be ignored for all connected pipe endpoints
| ignore |
|
inline |
Try dequeuing a packet from the receive queue.
Same as ReceivePacket(), but returns a bool for success or failure instead of throwing an exception
| packet | [out] the dequeued packet |
|
inline |
Try dequeuing a packet from the receive queue, optionally waiting or peeking the packet.
| packet | [out] the dequeued packet |
| timeout | The time to wait for a packet to be received in milliseconds if the queue is empty, or RR_TIMEOUT_INFINITE to wait forever |
| peek | If true, the packet is returned, but not dequeued. If false, the packet is dequeued |
| ep | [out] the PipeEndpoint that received the packet |