X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fserver_finder.h;h=dc62f998deb0d79f5e9926753fbd5c81c95f7559;hb=3b80b8f8a938dd34ee0e0fbca8fbce6a6850f136;hp=202bee8f920d9610bd82c50b6951ea701199ed25;hpb=ad49361b303d1ceff7048fa0e89ba609ca9ce376;p=dcpomatic.git diff --git a/src/lib/server_finder.h b/src/lib/server_finder.h index 202bee8f9..dc62f998d 100644 --- a/src/lib/server_finder.h +++ b/src/lib/server_finder.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Carl Hetherington + Copyright (C) 2013-2015 Carl Hetherington This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -17,27 +17,36 @@ */ -#include #include "server.h" +#include "signaller.h" +#include -class ServerFinder : public ExceptionStore +class ServerFinder : public Signaller, public ExceptionStore { public: - void connect (boost::function); + boost::signals2::connection connect (boost::function); static ServerFinder* instance (); + static void drop (); void disable () { _disabled = true; } + bool disabled () const { + return _disabled; + } + private: ServerFinder (); + ~ServerFinder (); void broadcast_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; @@ -51,5 +60,9 @@ private: std::list _servers; mutable boost::mutex _mutex; + boost::asio::io_service _listen_io_service; + boost::shared_ptr _listen_acceptor; + bool _stop; + static ServerFinder* _instance; };