Merge 1.0 and some subtitling fixes.
[dcpomatic.git] / src / lib / server_finder.h
index 8b56022de693fc36694c5cd20e210fff48a077c7..01e26f7dfee1aa3a7c432d8ba9c68c9d4e777057 100644 (file)
 class ServerFinder
 {
 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;
 };