Robot Raconteur Core C++ Library
|
Pipe endpoint used to transmit reliable or unreliable data streams. More...
Public Member Functions | |
boost::function< void(boost::shared_ptr< PipeEndpoint< T > >)> | GetPipeEndpointClosedCallback () |
Get the currently configured endpoint closed callback function. More... | |
void | SetPipeEndpointClosedCallback (boost::function< void(const boost::shared_ptr< PipeEndpoint< T > > &)> callback) |
Set the endpoint closed callback function. More... | |
virtual uint32_t | SendPacket (typename boost::call_traits< T >::param_type packet) |
Sends a packet to the peer endpoint. More... | |
virtual void | AsyncSendPacket (typename boost::call_traits< T >::param_type packet, boost::function< void(uint32_t, const boost::shared_ptr< RobotRaconteurException > &)> handler) |
Send a packet to the peer endpoint asynchronously. More... | |
virtual T | ReceivePacket () |
Receive the next packet in the receive queue. More... | |
virtual T | PeekNextPacket () |
Peeks the next packet in the receive queue. More... | |
virtual T | ReceivePacketWait (int32_t timeout=RR_TIMEOUT_INFINITE) |
Receive the next packet in the receive queue, block if queue is empty. More... | |
virtual T | PeekNextPacketWait (int32_t timeout=RR_TIMEOUT_INFINITE) |
Peek the next packet in the receive queue, block if queue is empty. More... | |
virtual bool | TryReceivePacketWait (T &val, int32_t timeout=RR_TIMEOUT_INFINITE, bool peek=false) |
Try receiving a packet, optionally blocking if the queue is empty. More... | |
RR_OVIRTUAL void | Close () RR_OVERRIDE |
Close the pipe endpoint. More... | |
RR_OVIRTUAL void | AsyncClose (boost::function< void(const boost::shared_ptr< RobotRaconteurException > &)> handler, int32_t timeout=2000) RR_OVERRIDE |
Asynchronously close the pipe endpoint. More... | |
virtual int32_t | GetIndex () |
Returns the pipe endpoint index used when endpoint connected. More... | |
virtual uint32_t | GetEndpoint () |
Returns the Robot Raconteur node Endpoint ID. More... | |
bool | GetRequestPacketAck () |
Get if pipe endpoint is requesting acks. More... | |
void | SetRequestPacketAck (bool ack) |
Set if pipe endpoint should request packet acks. More... | |
virtual size_t | Available () |
Return number of packets in the receive queue. More... | |
bool | IsUnreliable () |
Get if pipe endpoint is unreliable. More... | |
MemberDefinition_Direction | Direction () |
The direction of the pipe. More... | |
bool | GetIgnoreReceived () |
Get if pipe endpoint is ignoring incoming packets. More... | |
void | SetIgnoreReceived (bool ignore) |
Set whether pipe endpoint should ignore incoming packets. More... | |
Public Attributes | |
boost::signals2::signal< void(const boost::shared_ptr< PipeEndpoint< T > > &)> | PacketReceivedEvent |
Signal called when a packet has been received. More... | |
boost::signals2::signal< void(const boost::shared_ptr< PipeEndpoint< T > > &, uint32_t)> | PacketAckReceivedEvent |
Signal called when a packet ack has been received. More... | |
Pipe endpoint used to transmit reliable or unreliable data streams.
Pipe endpoints are used to communicate data between connected pipe members. See Pipe for more information on pipe members.
Pipe endpoints are created by clients using the Pipe::Connect() or Pipe::AsyncConnect() functions. Services receive incoming pipe endpoint connection requests through a callback function specified using the Pipe::SetPipeConnectCallback() function. Services may also use the PipeBroadcaster class to automate managing pipe endpoint lifecycles and sending packets to all connected client endpoints.
Pipe endpoints are indexed, meaning that more than one pipe endpoint pair can be created using the same member. This means that multiple data streams can be created independent of each other between the client and service using the same member.
Pipes send reliable packet streams between connected client/service endpoint pairs. Packets are sent using the SendPacket() or AsyncSendPacket() functions. Packets are read from the receive queue using the ReceivePacket(), ReceivePacketWait(), TryReceivePacketWait(), TryReceivePacketWait(), or PeekNextPacket(). The endpoint is closed using the Close() or AsyncClose() function.
This class is instantiated by the Pipe class. It should not be instantiated by the user.
T | The packet data type |
|
inlinevirtual |
Asynchronously close the pipe endpoint.
Same as Close() but returns asynchronously
handler | A handler function to call on completion, possibly with an exception |
timeout | Timeout in milliseconds, or RR_TIMEOUT_INFINITE for no timeout |
Reimplemented from RobotRaconteur::PipeEndpointBase.
|
inlinevirtual |
Send a packet to the peer endpoint asynchronously.
Same as SendPacket(), but returns asynchronously.
packet | The packet to send |
handler | A handler function to receive the sent packet number or an exception |
|
virtualinherited |
Return number of packets in the receive queue.
Invalid for writeonly pipes.
|
inlinevirtual |
Close the pipe endpoint.
Close the pipe endpoint. Blocks until close complete. The peer endpoint is destroyed automatically.
Reimplemented from RobotRaconteur::PipeEndpointBase.
|
inherited |
The direction of the pipe.
Pipes may be declared readonly or writeonly in the service definition file. (If neither is specified, the pipe is assumed to be full duplex.) readonly pipes may only send packets from service to client. writeonly pipes may only send packets from client to service.
|
virtualinherited |
Returns the Robot Raconteur node Endpoint ID.
Returns the endpoint associated with the ClientContext or ServerEndpoint associated with the pipe endpoint.
|
inherited |
|
virtualinherited |
Returns the pipe endpoint index used when endpoint connected.
|
inline |
Get the currently configured endpoint closed callback function.
|
inherited |
Get if pipe endpoint is requesting acks.
|
inherited |
Get if pipe endpoint is unreliable.
Pipe members may be declared as unreliable using member modifiers in the service definition. Pipes confirm unreliable operation when pipe endpoints are connected.
|
inlinevirtual |
Peeks the next packet in the receive queue.
Returns the first packet in the receive queue, but does not remove it from the queue. Throws an InvalidOperationException if there are no packets in the receive queue.
|
inlinevirtual |
Peek the next packet in the receive queue, block if queue is empty.
Same as PeekPacket(), but blocks if queue is empty
timeout | Timeout in milliseconds to wait for a packet, or RR_TIMEOUT_INFINITE for no timeout |
|
inlinevirtual |
Receive the next packet in the receive queue.
Receive the next packet from the receive queue. This function will throw an InvalidOperationException if there are no packets in the receive queue. Use ReceivePacketWait() to block until a packet has been received.
|
inlinevirtual |
Receive the next packet in the receive queue, block if queue is empty.
Same as ReceivePacket(), but blocks if queue is empty
timeout | Timeout in milliseconds to wait for a packet, or RR_TIMEOUT_INFINITE for no timeout |
|
inlinevirtual |
Sends a packet to the peer endpoint.
Sends a packet to the peer endpoint. If the pipe is reliable, the packetsare guaranteed to arrive in order. If the pipe is set to unreliable, "best effort" is made to deliver packets, and they are not guaranteed to arrive in order. This function will block until the packet has been transmitted by the transport. It will return before the peer endpoint has received the packet.
packet | The packet to send |
|
inherited |
Set whether pipe endpoint should ignore incoming packets.
Pipe endpoints may optionally desire to ignore incoming data. This is useful if the endpoint is only being used to send packets, and received packets may create a potential memory leak if they are not being removed from the queue. If ignore is true, incoming packets will be discarded and will not be added to the receive queue.
ignore | If true, incoming packets are ignored. If false, the packets are added to the receive queue. |
|
inline |
Set the endpoint closed callback function.
Sets a function to invoke when the pipe endpoint has been closed.
Callback function must accept one argument, receiving the PipeEndpointPtr<T> that was closed.
callback | The callback function |
|
inherited |
Set if pipe endpoint should request packet acks.
Packet acks are generated by receiving endpoints to inform the sender that a packet has been received. The ack contains the packet index, the sequence number of the packet. Packet acks are used for flow control by PipeBroadcaster.
ack | true to request packet acks, otherwise false |
|
inlinevirtual |
Try receiving a packet, optionally blocking if the queue is empty.
Try receiving a packet with various options. Returns true if a packet has been received, or false if no packet is available instead of throwing an exception on failure. The timeout and peek parameters can be used to modify behavior to provide functionality similar to the various Receive and Peek functions.
val | [out] The received packet |
timeout | The timeout in milliseconds. Set to zero for non-blocking operation, an arbitrary value in milliseconds for a finite duration timeout, or RR_TIMEOUT_INFINITE for no timeout |
peek | If true, the packet is not removed from the receive queue |
boost::signals2::signal<void(const boost::shared_ptr<PipeEndpoint<T> >&, uint32_t)> RobotRaconteur::PipeEndpoint< T >::PacketAckReceivedEvent |
Signal called when a packet ack has been received.
Packet acks are generated if SetRequestPacketAck() is set to true. The receiving endpoint generates acks to inform the sender that the packet has been received.
Callback function must accept two arguments, receiving the PipeEndpointPtr<T> that received the packet ack and the packet number that is being acked.
boost::signals2::signal<void(const boost::shared_ptr<PipeEndpoint<T> >&)> RobotRaconteur::PipeEndpoint< T >::PacketReceivedEvent |
Signal called when a packet has been received.
Callback function must accept one argument, receiving the PipeEndpointPtr<T> that received a packet