NAP
Public Member Functions | Public Attributes | Protected Member Functions | List of all members
UDPClient Class Referencefinal

#include <udpclient.h>

Public Member Functions

 UDPClient ()
 
virtual ~UDPClient ()
 
void send (const UDPPacket &packet)
 
void send (UDPPacket &&packet)
 
- Public Member Functions inherited from UDPAdapter
 UDPAdapter ()
 
virtual ~UDPAdapter ()
 
virtual bool init (utility::ErrorState &errorState) override final
 
virtual void onDestroy () override final
 
virtual bool start (utility::ErrorState &errorState) override final
 
virtual void stop () override final
 
- Public Member Functions inherited from Resource
 Resource ()
 
- Public Member Functions inherited from Object
 Object ()
 
virtual ~Object ()
 
 Object (Object &)=delete
 
Objectoperator= (const Object &)=delete
 
 Object (Object &&)=delete
 
Objectoperator= (Object &&)=delete
 

Public Attributes

int mPort = 13251
 Property: 'Port' the port the client socket binds to. More...
 
std::string mEndpoint = "10.8.0.3"
 Property: 'Endpoint' the ip address the client socket binds to. More...
 
int mMaxPacketQueueSize = 1000
 Property: 'MaxQueueSize' maximum of queued packets. More...
 
bool mStopOnMaxQueueSizeExceeded = true
 Property: 'StopOnMaxQueueSizeExceeded' stop adding packets when queue size is exceed. More...
 
bool mBroadcast = false
 Property: 'Broadcast' set option to broadcast. More...
 
- Public Attributes inherited from UDPAdapter
ResourcePtr< UDPThreadmThread
 Property: 'Thread' the udp thread the adapter registers itself to. More...
 
bool mAllowFailure = false
 Property: 'AllowFailure' if binding to socket is allowed to fail on initialization. More...
 
- Public Attributes inherited from Object
std::string mID
 Property: 'mID' unique name of the object. Used as an identifier by the system. More...
 

Protected Member Functions

bool onStart (utility::ErrorState &errorState) override final
 
void onStop () override final
 
void onProcess () override final
 
- Protected Member Functions inherited from UDPAdapter
void process ()
 
bool handleAsioError (const std::error_code &errorCode, utility::ErrorState &errorState, bool &success)
 
asio::io_context & getIOContext ()
 

Additional Inherited Members

- Static Public Member Functions inherited from Object
static bool isIDProperty (rtti::Instance &object, const rtti::Property &property)
 

Description

The UDP Client class is used to send UDP Packets to an endpoint.

Inheritance diagram for UDPClient:
[legend]
Collaboration diagram for UDPClient:
[legend]

Constructor & Destructor Documentation

◆ UDPClient()

UDPClient ( )

Constructor

◆ ~UDPClient()

virtual ~UDPClient ( )
virtual

Destructor

Member Function Documentation

◆ onProcess()

void onProcess ( )
finaloverrideprotectedvirtual

The process function

Implements UDPAdapter.

◆ onStart()

bool onStart ( utility::ErrorState errorState)
finaloverrideprotectedvirtual

Starts the UDP client and creates the socket

Parameters
errorStatecontains error information
Returns
true on success

Implements UDPAdapter.

◆ onStop()

void onStop ( )
finaloverrideprotectedvirtual

Called when socket needs to be closed

Implements UDPAdapter.

◆ send() [1/2]

void send ( const UDPPacket packet)

Makes a copy of the packet and queues if for sending. Call send(std::move(packet)) if you want to move the packet instead. Calling this method is Thread-Safe.

Parameters
packetto send

◆ send() [2/2]

void send ( UDPPacket &&  packet)

Moves and queues the packet for sending. Calling this method is Thread-Safe.

Parameters
packetto send

Member Data Documentation

◆ mBroadcast

bool mBroadcast = false

Property: 'Broadcast' set option to broadcast.

◆ mEndpoint

std::string mEndpoint = "10.8.0.3"

Property: 'Endpoint' the ip address the client socket binds to.

◆ mMaxPacketQueueSize

int mMaxPacketQueueSize = 1000

Property: 'MaxQueueSize' maximum of queued packets.

◆ mPort

int mPort = 13251

Property: 'Port' the port the client socket binds to.

◆ mStopOnMaxQueueSizeExceeded

bool mStopOnMaxQueueSizeExceeded = true

Property: 'StopOnMaxQueueSizeExceeded' stop adding packets when queue size is exceed.