summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/LinkLocal/LinkLocalRoster.cpp')
-rw-r--r--Swiften/LinkLocal/LinkLocalRoster.cpp21
1 files changed, 17 insertions, 4 deletions
diff --git a/Swiften/LinkLocal/LinkLocalRoster.cpp b/Swiften/LinkLocal/LinkLocalRoster.cpp
index fde52a9..feec7b7 100644
--- a/Swiften/LinkLocal/LinkLocalRoster.cpp
+++ b/Swiften/LinkLocal/LinkLocalRoster.cpp
@@ -2,15 +2,17 @@
#include <iostream>
#include "Swiften/LinkLocal/LinkLocalRoster.h"
+#include "Swiften/Network/HostAddress.h"
namespace Swift {
LinkLocalRoster::LinkLocalRoster(boost::shared_ptr<DNSSDService> service) : dnsSDService(service) {
+ dnsSDService->onStopped.connect(boost::bind(&LinkLocalRoster::handleStopped, this, _1));
+ dnsSDService->onServiceRegistered.connect(boost::bind(&LinkLocalRoster::handleServiceRegistered, 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));
+ dnsSDService->onHostnameResolved.connect(boost::bind(&LinkLocalRoster::handleHostnameResolved, this, _1, _2));
}
void LinkLocalRoster::handleServiceAdded(const DNSSDService::Service& service) {
@@ -28,14 +30,25 @@ void LinkLocalRoster::handleServiceRemoved(const DNSSDService::Service& 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;
+ dnsSDService->resolveHostname(result.host);
}
+void LinkLocalRoster::handleHostnameResolved(const String& hostname, const boost::optional<HostAddress>& address) {
+ if (address) {
+ std::cout << "Address resolved: " << hostname << " " << address->toString() << std::endl;
+ }
+ else {
+ std::cout << "Unable to resolve address for " << hostname << std::endl;
+ }
+}
+
+
void LinkLocalRoster::handleServiceRegistered(const DNSSDService::Service& service) {
selfService = service;
}
-void LinkLocalRoster::handleDNSSDError() {
- std::cout << "DNSSD Error" << std::endl;
+void LinkLocalRoster::handleStopped(bool error) {
+ std::cout << "DNSSDService stopped: " << error << std::endl;
}
}