#pragma once #include #include #include #include #include #include "Swiften/LinkLocal/DNSSD/DNSSDQuerier.h" #include "Swiften/LinkLocal/DNSSD/Bonjour/BonjourQuery.h" namespace Swift { class LinkLocalServiceInfo; class BonjourQuerier : public DNSSDQuerier, public boost::enable_shared_from_this { public: BonjourQuerier(); ~BonjourQuerier(); boost::shared_ptr createBrowseQuery(); boost::shared_ptr createRegisterQuery( const String& name, int port, const LinkLocalServiceInfo& info); boost::shared_ptr createResolveServiceQuery( const LinkLocalServiceID&); boost::shared_ptr createResolveHostnameQuery( const String& hostname, int interfaceIndex); void start(); void stop(); private: friend class BonjourQuery; void addRunningQuery(boost::shared_ptr); void removeRunningQuery(boost::shared_ptr); void interruptSelect(); void run(); private: bool stopRequested; boost::thread* thread; boost::mutex runningQueriesMutex; std::list< boost::shared_ptr > runningQueries; int interruptSelectReadSocket; int interruptSelectWriteSocket; boost::condition_variable runningQueriesAvailableEvent; }; }