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

The calling of serviceResolved for a particular service is incrementally increased #7

Open
soroshsabz opened this issue Sep 14, 2017 · 1 comment

Comments

@soroshsabz
Copy link

ITNOA

Hi,

I have a main code like below

dnssd_responder.start();

dnssd_responder.browser().serviceFound += Poco::delegate(on_service_found);
dnssd_responder.browser().serviceResolved += Poco::delegate(on_service_resolved);

Poco::DNSSD::Service service("_test._udp", 3000);

dnssd_responder.browse().browse("_test._udp", "local");

auto service_handle = dnssd_responder.registerService(service);
std::this_thread::sleep_for(3s);
dnssd_responder.unregisterService(service_handle);
service_handle = dnssd_responder.registerService(service);
dnssd_responder.unregisterService(service_handle);

and i have a simple implementaion for event handlers like below

void on_service_found(const void* sender, const Poco::DNSSD::DNSSDBrowser::ServiceEventArgs& arguments)
{
    reinterpret_cast<Poco::DNSSD::DNSSDBrowser*>(const_cast<void*>(sender))->resolve(arguments.service));
}

void on_service_resolved(const void* sender, const Poco::DNSSD::DNSSDBrowser::ServiceEventArgs& arguments)
{
    static int a = 0;
    std::cout << "number of on service resolved calls: " << ++a << std::endl;
}

I expect that after the run program i see 2 line and last a equal to 2, but i see 3 line and last a equal to 3.

I think the problem is resolver run in background continuously, for each on_service_found called and it does not stop after new resolve called. However, the documentation of resolve method in DNSSDBrowser.h file says: "After either the serviceResolved or resolveError event has been fired, the returend BrowseHandle is no longer valid" so i think resolve will be stop after fire serviceResolved, But it does not follow behavior that i guess.

I have two question about that:

  1. Is this an bug or not?
  2. If this does not a bug, so what is the solution for call on_service_resolve only twice?

thanks a lot

@thegreathir
Copy link

No answer?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants