X-Git-Url: https://main.carlh.net/gitweb/?p=dcpomatic.git;a=blobdiff_plain;f=src%2Flib%2Fserver_finder.h;h=8aa07c0696145918cc64f5a8cc09fb35f98cbbb3;hp=dc62f998deb0d79f5e9926753fbd5c81c95f7559;hb=aeb835a18c8df347e0ed68fb24631b320abeb611;hpb=6f0a590bc3266f21ba577116219bd019e891d480 diff --git a/src/lib/server_finder.h b/src/lib/server_finder.h index dc62f998d..8aa07c069 100644 --- a/src/lib/server_finder.h +++ b/src/lib/server_finder.h @@ -17,15 +17,22 @@ */ -#include "server.h" +/** @file src/lib/server_finder.h + * @brief ServerFinder class. + */ + #include "signaller.h" +#include "server_description.h" +#include "config.h" +#include "exception_store.h" #include +#include + +class Socket; class ServerFinder : public Signaller, public ExceptionStore { public: - boost::signals2::connection connect (boost::function); - static ServerFinder* instance (); static void drop (); @@ -37,32 +44,43 @@ public: return _disabled; } + std::list servers () const; + + /** Emitted whenever the list of servers changes */ + boost::signals2::signal ServersListChanged; + private: ServerFinder (); ~ServerFinder (); - void broadcast_thread (); + void start (); + + void search_thread (); void listen_thread (); bool server_found (std::string) const; void start_accept (); void handle_accept (boost::system::error_code ec, boost::shared_ptr socket); - boost::signals2::signal ServerFound; + void config_changed (Config::Property what); + void search_now (); bool _disabled; - - /** Thread to periodically issue broadcasts to find encoding servers */ - boost::thread* _broadcast_thread; + + /** Thread to periodically issue broadcasts and requests to find encoding servers */ + boost::thread* _search_thread; /** Thread to listen to the responses from servers */ boost::thread* _listen_thread; std::list _servers; - mutable boost::mutex _mutex; + mutable boost::mutex _servers_mutex; boost::asio::io_service _listen_io_service; boost::shared_ptr _listen_acceptor; bool _stop; + boost::condition _search_condition; + boost::mutex _search_condition_mutex; + static ServerFinder* _instance; };