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

#include <udpserver.h>

Public Member Functions

 UDPServer ()
 
virtual ~UDPServer ()
 
void registerListenerSlot (Slot< const UDPPacket & > &slot)
 
void removeListenerSlot (Slot< const UDPPacket & > &slot)
 
- 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 server socket binds to. More...
 
std::string mIPAddress = ""
 Property: 'IP Address' local ip address to bind to, if left empty will bind to any local address. More...
 
std::vector< std::string > mMulticastGroups
 Property: 'Multicast Groups' multicast groups to join. 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

virtual bool onStart (utility::ErrorState &errorState) override final
 
virtual 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 ()
 

Protected Attributes

Signal< const UDPPacket & > packetReceived
 

Additional Inherited Members

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

Description

The UDP Server connects to an endpoint and receives any UDP packets sent to the endpoint. The server will invoke the packetReceived signal when packets are received. The signal will be fired on the thread this UDPServer is registered to, see UDPThread.

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

Constructor & Destructor Documentation

◆ UDPServer()

UDPServer ( )

Constructor

◆ ~UDPServer()

virtual ~UDPServer ( )
virtual

Destructor

Member Function Documentation

◆ onProcess()

void onProcess ( )
finaloverrideprotectedvirtual

The process function

Implements UDPAdapter.

◆ onStart()

virtual bool onStart ( utility::ErrorState errorState)
finaloverrideprotectedvirtual

Called when server socket needs to be created

Parameters
errorStateThe error state
Returns
: true on success

Implements UDPAdapter.

◆ onStop()

virtual void onStop ( )
finaloverrideprotectedvirtual

Called when socket needs to be closed

Implements UDPAdapter.

◆ registerListenerSlot()

void registerListenerSlot ( Slot< const UDPPacket & > &  slot)

Connects a listener slot to the packetReceived signal. Thread-Safe

Parameters
slotthe slot that will be invoked when a packet is received

◆ removeListenerSlot()

void removeListenerSlot ( Slot< const UDPPacket & > &  slot)

Disconnects a listener slot from the packetReceived signal. Thread-Safe

Parameters
slotthe slot that will be disconnected

Member Data Documentation

◆ mIPAddress

std::string mIPAddress = ""

Property: 'IP Address' local ip address to bind to, if left empty will bind to any local address.

◆ mMulticastGroups

std::vector<std::string> mMulticastGroups

Property: 'Multicast Groups' multicast groups to join.

◆ mPort

int mPort = 13251

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

◆ packetReceived

Signal<const UDPPacket&> packetReceived
protected

packet received signal will be dispatched on the thread this UDPServer is registered to, see UDPThread