Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add domain names matching the DnssdServices stored in Browse Context #32740

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions src/platform/Darwin/DnssdContexts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,12 @@ void BrowseContext::DispatchSuccess()
void BrowseContext::DispatchPartialSuccess()
{
sContextDispatchingSuccess = this;
callback(context, services.data(), services.size(), false, CHIP_NO_ERROR);
std::vector<DnssdService> dnsServices;
for (auto iter : services)
{
dnsServices.push_back(std::move(iter.first));
}
callback(context, dnsServices.data(), dnsServices.size(), false, CHIP_NO_ERROR);
sContextDispatchingSuccess = nullptr;
services.clear();
}
Expand All @@ -390,7 +395,7 @@ void BrowseContext::OnBrowseAdd(const char * name, const char * type, const char

VerifyOrReturn(IsLocalDomain(domain));
auto service = GetService(name, type, protocol, interfaceId);
services.push_back(service);
services.push_back(std::make_pair(std::move(service), std::string(domain)));
}

void BrowseContext::OnBrowseRemove(const char * name, const char * type, const char * domain, uint32_t interfaceId)
Expand All @@ -402,9 +407,10 @@ void BrowseContext::OnBrowseRemove(const char * name, const char * type, const c
VerifyOrReturn(IsLocalDomain(domain));

services.erase(std::remove_if(services.begin(), services.end(),
[name, type, interfaceId](const DnssdService & service) {
return strcmp(name, service.mName) == 0 && type == GetFullType(&service) &&
service.mInterface == chip::Inet::InterfaceId(interfaceId);
[name, type, interfaceId, domain](const auto & service) {
return strcmp(name, service.first.mName) == 0 && type == GetFullType(&service.first) &&
service.first.mInterface == chip::Inet::InterfaceId(interfaceId) &&
strcmp(domain, service.second.c_str()) == 0;
}),
services.end());
}
Expand Down
2 changes: 1 addition & 1 deletion src/platform/Darwin/DnssdImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ struct BrowseHandler : public GenericContext
struct BrowseContext : public BrowseHandler
{
DnssdBrowseCallback callback;
std::vector<DnssdService> services;
std::vector<std::pair<DnssdService, std::string>> services;

BrowseContext(void * cbContext, DnssdBrowseCallback cb, DnssdServiceProtocol cbContextProtocol);

Expand Down
Loading