Some include tidying.
[dcpomatic.git] / src / lib / server_finder.h
index 8b56022de693fc36694c5cd20e210fff48a077c7..6f02042cee6034827e4a6ad0d4b8ca9e0f0cc988 100644 (file)
 
 */
 
-#include <boost/signals2.hpp>
 #include "server.h"
+#include <boost/signals2.hpp>
 
-class ServerFinder
+class ServerFinder : public ExceptionStore
 {
 public:
-       ServerFinder ();
-       ~ServerFinder ();
+       void connect (boost::function<void (ServerDescription)>);
 
-       boost::signals2::signal<void (ServerDescription)> 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<void (ServerDescription)> 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<ServerDescription> _servers;
+       mutable boost::mutex _mutex;
+
+       static ServerFinder* _instance;
 };