#include <boost/signals2.hpp>
#include "server.h"
-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;
};