Class nebula::drivers::connections::UdpSocket
ClassList > nebula > drivers > connections > UdpSocket
#include <udp.hpp>
Classes
Type | Name |
---|---|
class | Builder |
struct | RxMetadata |
Public Types
Type | Name |
---|---|
typedef std::function< void(const std::vector< uint8_t > &, const RxMetadata &)> | callback_t |
Public Functions
Type | Name |
---|---|
UdpSocket (const UdpSocket &) = delete |
|
UdpSocket (UdpSocket && other) |
|
bool | is_subscribed () |
UdpSocket & | operator= (const UdpSocket &) = delete |
UdpSocket & | operator= (UdpSocket &&) = delete |
void | send (const std::vector< uint8_t > & data) Send a datagram to the destination set in set_send_destination() . |
UdpSocket & | subscribe (callback_t && callback) Register a callback for processing received packets and start the receiver thread. The callback will be called for each received packet, and will be executed in the receive thread. Has to be called on a bound socket ( bind() has to have been called before). |
UdpSocket & | unsubscribe () Gracefully stops the active receiver thread (if any) but keeps the socket alive. The same socket can later be subscribed again. |
~UdpSocket () |
Public Types Documentation
typedef callback_t
using nebula::drivers::connections::UdpSocket::callback_t = std::function<void(const std::vector<uint8_t> &, const RxMetadata &)>;
Public Functions Documentation
function UdpSocket [2/3]
nebula::drivers::connections::UdpSocket::UdpSocket (
const UdpSocket &
) = delete
function UdpSocket [3/3]
inline nebula::drivers::connections::UdpSocket::UdpSocket (
UdpSocket && other
)
function is_subscribed
inline bool nebula::drivers::connections::UdpSocket::is_subscribed ()
function operator=
UdpSocket & nebula::drivers::connections::UdpSocket::operator= (
const UdpSocket &
) = delete
function operator=
UdpSocket & nebula::drivers::connections::UdpSocket::operator= (
UdpSocket &&
) = delete
function send
Send a datagram to the destination set in set_send_destination()
.
inline void nebula::drivers::connections::UdpSocket::send (
const std::vector< uint8_t > & data
)
Parameters:
data
The data to send
Exception:
- UsageError If no destination has been set via
set_send_destination()
- SocketError If the send operation fails
function subscribe
Register a callback for processing received packets and start the receiver thread. The callback will be called for each received packet, and will be executed in the receive thread. Has to be called on a bound socket ( bind()
has to have been called before).
inline UdpSocket & nebula::drivers::connections::UdpSocket::subscribe (
callback_t && callback
)
Parameters:
callback
The function to be executed for each received packet.
function unsubscribe
Gracefully stops the active receiver thread (if any) but keeps the socket alive. The same socket can later be subscribed again.
inline UdpSocket & nebula::drivers::connections::UdpSocket::unsubscribe ()
function ~UdpSocket
inline nebula::drivers::connections::UdpSocket::~UdpSocket ()
The documentation for this class was generated from the following file nebula_hw_interfaces/include/nebula_hw_interfaces/nebula_hw_interfaces_common/connections/udp.hpp