lib/avahi/Publisher: move code to RegisterServices(AvahiEntryGroup)

This commit is contained in:
Max Kellermann 2024-01-17 18:51:47 +01:00 committed by Max Kellermann
parent 1b241fc97a
commit 4a14248004
2 changed files with 13 additions and 6 deletions

View File

@ -83,7 +83,7 @@ try {
}
/* And recreate the services */
RegisterServices(avahi_entry_group_get_client(g));
RegisterServices(*g);
break;
case AVAHI_ENTRY_GROUP_FAILURE:
@ -129,6 +129,16 @@ AddServices(AvahiEntryGroup &group,
AddService(group, i, name);
}
void
Publisher::RegisterServices(AvahiEntryGroup &g)
{
AddServices(g, services, name.c_str());
if (int error = avahi_entry_group_commit(&g);
error != AVAHI_OK)
throw MakeError(error, "Failed to commit Avahi service group");
}
void
Publisher::RegisterServices(AvahiClient *c)
{
@ -140,11 +150,7 @@ Publisher::RegisterServices(AvahiClient *c)
throw MakeError(*c, "Failed to create Avahi service group");
}
AddServices(*group, services, name.c_str());
if (int error = avahi_entry_group_commit(group.get());
error != AVAHI_OK)
throw MakeError(error, "Failed to commit Avahi service group");
RegisterServices(*group);
}
void

View File

@ -68,6 +68,7 @@ private:
AvahiEntryGroupState state,
void *userdata) noexcept;
void RegisterServices(AvahiEntryGroup &g);
void RegisterServices(AvahiClient *c);
/* virtual methods from class AvahiConnectionListener */