mDNS::Server Class Reference
Locates mDNS services by issuing queries. More...
#include <Server.h>
Inheritance diagram for mDNS::Server:
Collaboration diagram for mDNS::Server:
Public Types | |
using | MessageDelegate = Delegate< bool(Message &message)> |
Callback to be invoked for each received message. More... | |
using | PacketDelegate = Delegate< bool(IpAddress remoteIP, uint16_t remotePort, const uint8_t *data, size_t length)> |
Callback to be invoked with raw data (debugging, etc.) More... | |
Public Member Functions | |
~Server () | |
bool | begin () |
void | end () |
bool | restart () |
void | addHandler (Handler &handler) |
Set callback to be invoked for each received message. More... | |
void | removeHandler (Handler &handler) |
Remove a message handler. More... | |
void | onSend (MessageDelegate callback) |
Set callback to be invoked before sending a message. More... | |
void | onPacket (PacketDelegate callback) |
Set callback to be invoked for raw received data, before parsing. More... | |
bool | search (const String &hostname, ResourceType type=ResourceType::PTR) |
Send a multicast query. More... | |
bool | send (Message &message) |
Send an mDNS message containing questions/answers. More... | |
Protected Member Functions | |
void | onReceive (pbuf *buf, IpAddress remoteIP, uint16_t remotePort) override |
![]() | |
bool | initialize (udp_pcb *pcb=nullptr) |
UdpConnection () | |
UdpConnection (UdpConnectionDataDelegate dataHandler) | |
virtual | ~UdpConnection () |
virtual bool | listen (int port) |
virtual bool | connect (IpAddress ip, uint16_t port) |
virtual void | close () |
virtual bool | send (const char *data, int length) |
bool | sendString (const char *data) |
bool | sendString (const String &data) |
virtual bool | sendTo (IpAddress remoteIP, uint16_t remotePort, const char *data, int length) |
bool | sendStringTo (IpAddress remoteIP, uint16_t remotePort, const char *data) |
bool | sendStringTo (IpAddress remoteIP, uint16_t remotePort, const String &data) |
bool | setMulticast (IpAddress ip) |
Sets the UDP multicast IP. More... | |
bool | setMulticastTtl (size_t ttl) |
Sets the UDP multicast Time-To-Live(TTL). More... | |
![]() | |
bool | joinMulticastGroup (IpAddress localIp, IpAddress multicastIp) |
Uses IGMP to add a local network interface to multicast group. More... | |
bool | joinMulticastGroup (IpAddress multicastIp) |
Uses IGMP to add all local network interfaces to multicast group. More... | |
bool | leaveMulticastGroup (IpAddress localIp, IpAddress multicastIp) |
Uses IGMP to remove a local network interface from multicast group. More... | |
bool | leaveMulticastGroup (IpAddress multicastIp) |
Uses IGMP to remove all local network interfaces from multicast group. More... | |
Additional Inherited Members | |
![]() | |
static void | staticOnReceive (void *arg, struct udp_pcb *pcb, struct pbuf *p, LWIP_IP_ADDR_T *addr, u16_t port) |
![]() | |
udp_pcb * | udp = nullptr |
UdpConnectionDataDelegate | onDataCallback = nullptr |
Detailed Description
Locates mDNS services by issuing queries.
Member Typedef Documentation
◆ MessageDelegate
using mDNS::Server::MessageDelegate = Delegate<bool(Message& message)> |
Callback to be invoked for each received message.
- Return values
-
bool See onSend()
◆ PacketDelegate
using mDNS::Server::PacketDelegate = Delegate<bool(IpAddress remoteIP, uint16_t remotePort, const uint8_t* data, size_t length)> |
Callback to be invoked with raw data (debugging, etc.)
- Return values
-
bool See onPacket()
Constructor & Destructor Documentation
◆ ~Server()
mDNS::Server::~Server | ( | ) |
Member Function Documentation
◆ addHandler()
|
inline |
Set callback to be invoked for each received message.
- Parameters
-
callback Return false from callback to prevent message being passed to other clients
◆ begin()
bool mDNS::Server::begin | ( | ) |
◆ end()
void mDNS::Server::end | ( | ) |
◆ onPacket()
|
inline |
Set callback to be invoked for raw received data, before parsing.
- Parameters
-
callback Return true from callback to actually send packet
◆ onReceive()
|
overrideprotectedvirtual |
Reimplemented from UdpConnection.
◆ onSend()
|
inline |
Set callback to be invoked before sending a message.
- Parameters
-
callback Return true from callback to actually send packet
◆ removeHandler()
|
inline |
Remove a message handler.
- Note
- If there are no more handlers then consider setting a timeout and then shutting the server down.
◆ restart()
|
inline |
◆ search()
bool mDNS::Server::search | ( | const String & | hostname, |
ResourceType | type = ResourceType::PTR |
||
) |
Send a multicast query.
- Parameters
-
hostname Name to find, e.g. "_googlecast._tcp.local" type
- Return values
-
bool false if parameters failed validation or UDP request could not be sent
◆ send()
Send an mDNS message containing questions/answers.
- Return values
-
bool true if message sent successfully
The documentation for this class was generated from the following file: