diff options
Diffstat (limited to 'Swiften/LinkLocal/LinkLocalRoster.cpp')
-rw-r--r-- | Swiften/LinkLocal/LinkLocalRoster.cpp | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/Swiften/LinkLocal/LinkLocalRoster.cpp b/Swiften/LinkLocal/LinkLocalRoster.cpp index 9f7e4ad..fde52a9 100644 --- a/Swiften/LinkLocal/LinkLocalRoster.cpp +++ b/Swiften/LinkLocal/LinkLocalRoster.cpp @@ -6,16 +6,36 @@ namespace Swift { LinkLocalRoster::LinkLocalRoster(boost::shared_ptr<DNSSDService> service) : dnsSDService(service) { - service->onServiceAdded.connect(boost::bind(&LinkLocalRoster::handleServiceAdded, this, _1)); - service->onServiceRemoved.connect(boost::bind(&LinkLocalRoster::handleServiceRemoved, this, _1)); + dnsSDService->onServiceAdded.connect(boost::bind(&LinkLocalRoster::handleServiceAdded, this, _1)); + dnsSDService->onServiceRemoved.connect(boost::bind(&LinkLocalRoster::handleServiceRemoved, this, _1)); + dnsSDService->onServiceResolved.connect(boost::bind(&LinkLocalRoster::handleServiceResolved, this, _1, _2)); + dnsSDService->onError.connect(boost::bind(&LinkLocalRoster::handleDNSSDError, this)); + dnsSDService->onServiceRegistered.connect(boost::bind(&LinkLocalRoster::handleServiceRegistered, this, _1)); } void LinkLocalRoster::handleServiceAdded(const DNSSDService::Service& service) { + if (selfService && *selfService == service) { + return; + } std::cout << "Service added " << service.name << " " << service.type << " " << service.domain << std::endl; + dnsSDService->startResolvingService(service); } void LinkLocalRoster::handleServiceRemoved(const DNSSDService::Service& service) { std::cout << "Service removed " << service.name << " " << service.type << " " << service.domain << std::endl; + dnsSDService->stopResolvingService(service); +} + +void LinkLocalRoster::handleServiceResolved(const DNSSDService::Service& service, const DNSSDService::ResolveResult& result) { + std::cout << "Service resolved: " << service.name << "->" << result.host << " " << result.port << " " << result.info.getLastName() << std::endl; +} + +void LinkLocalRoster::handleServiceRegistered(const DNSSDService::Service& service) { + selfService = service; +} + +void LinkLocalRoster::handleDNSSDError() { + std::cout << "DNSSD Error" << std::endl; } } |