zeroconf/Bonjour: convert the callback function to a method

This commit is contained in:
Max Kellermann
2021-02-24 13:58:18 +01:00
parent 0157643667
commit 4fbdb3a2d5

View File

@@ -56,6 +56,12 @@ public:
socket_event.Cancel(); socket_event.Cancel();
} }
static void Callback(DNSServiceRef sdRef, DNSServiceFlags flags,
DNSServiceErrorType errorCode, const char *name,
const char *regtype,
const char *domain,
void *context) noexcept;
protected: protected:
/* virtual methods from class SocketMonitor */ /* virtual methods from class SocketMonitor */
void OnSocketReady([[maybe_unused]] unsigned flags) noexcept { void OnSocketReady([[maybe_unused]] unsigned flags) noexcept {
@@ -65,13 +71,13 @@ protected:
static BonjourHelper *bonjour_monitor; static BonjourHelper *bonjour_monitor;
static void void
dnsRegisterCallback([[maybe_unused]] DNSServiceRef sdRef, BonjourHelper::Callback([[maybe_unused]] DNSServiceRef sdRef,
[[maybe_unused]] DNSServiceFlags flags, [[maybe_unused]] DNSServiceFlags flags,
DNSServiceErrorType errorCode, const char *name, DNSServiceErrorType errorCode, const char *name,
[[maybe_unused]] const char *regtype, [[maybe_unused]] const char *regtype,
[[maybe_unused]] const char *domain, [[maybe_unused]] const char *domain,
[[maybe_unused]] void *context) [[maybe_unused]] void *context) noexcept
{ {
if (errorCode != kDNSServiceErr_NoError) { if (errorCode != kDNSServiceErr_NoError) {
LogError(bonjour_domain, LogError(bonjour_domain,
@@ -94,7 +100,7 @@ BonjourInit(EventLoop &loop, const char *service_name, unsigned port)
SERVICE_TYPE, nullptr, nullptr, SERVICE_TYPE, nullptr, nullptr,
htons(port), 0, htons(port), 0,
nullptr, nullptr,
dnsRegisterCallback, BonjourHelper::Callback,
nullptr); nullptr);
if (error != kDNSServiceErr_NoError) { if (error != kDNSServiceErr_NoError) {