/* * Copyright (c) 2010 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #pragma once #include #include #include #include #include #include #include #include namespace Swift { class BonjourQuerier : public DNSSDQuerier, public boost::enable_shared_from_this { public: BonjourQuerier(EventLoop* eventLoop); ~BonjourQuerier(); boost::shared_ptr createBrowseQuery(); boost::shared_ptr createRegisterQuery( const std::string& name, int port, const ByteArray& info); boost::shared_ptr createResolveServiceQuery( const DNSSDServiceID&); boost::shared_ptr createResolveHostnameQuery( const std::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: EventLoop* eventLoop; bool stopRequested; boost::thread* thread; boost::mutex runningQueriesMutex; std::list< boost::shared_ptr > runningQueries; int interruptSelectReadSocket; int interruptSelectWriteSocket; boost::condition_variable runningQueriesAvailableEvent; }; }