X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fserver_finder.h;h=202bee8f920d9610bd82c50b6951ea701199ed25;hb=7979aeb87a83de31c4cf25f88eef4fbca4b56553;hp=8b56022de693fc36694c5cd20e210fff48a077c7;hpb=d98bdad019ba9be5d800dece0414d7a080609027;p=dcpomatic.git diff --git a/src/lib/server_finder.h b/src/lib/server_finder.h index 8b56022de..202bee8f9 100644 --- a/src/lib/server_finder.h +++ b/src/lib/server_finder.h @@ -20,22 +20,36 @@ #include #include "server.h" -class ServerFinder +class ServerFinder : public ExceptionStore { public: - ServerFinder (); - ~ServerFinder (); + void connect (boost::function); - boost::signals2::signal ServerFound; + static ServerFinder* instance (); + + void disable () { + _disabled = true; + } private: + ServerFinder (); + void broadcast_thread (); void listen_thread (); + + bool server_found (std::string) const; + + boost::signals2::signal ServerFound; + + bool _disabled; - /** A thread to periodically issue broadcasts to find encoding servers */ + /** Thread to periodically issue broadcasts to find encoding servers */ boost::thread* _broadcast_thread; + /** Thread to listen to the responses from servers */ boost::thread* _listen_thread; - bool _terminate; - boost::mutex _mutex; + std::list _servers; + mutable boost::mutex _mutex; + + static ServerFinder* _instance; };