Tinker with verbosity of command-line server.
[dcpomatic.git] / src / lib / server.h
index 6307c1867686575fe3ac99ba9e13e0eaf5f2c238..abc5676d8a076685a39c3ea2957a3557cc66e63b 100644 (file)
@@ -17,6 +17,9 @@
 
 */
 
+#ifndef DCPOMATIC_SERVER_H
+#define DCPOMATIC_SERVER_H
+
 /** @file src/server.h
  *  @brief Class to describe a server to which we can send
  *  encoding work, and a class to implement such a server.
@@ -26,6 +29,7 @@
 #include <boost/thread.hpp>
 #include <boost/asio.hpp>
 #include <boost/thread/condition.hpp>
+#include <boost/optional.hpp>
 #include <libxml++/libxml++.h>
 #include "log.h"
 
@@ -78,7 +82,7 @@ public:
 
        void as_xml (xmlpp::Node *) const;
        
-       static boost::shared_ptr<ServerDescription> create_from_metadata (std::string v);
+       static boost::optional<ServerDescription> create_from_metadata (std::string);
 
 private:
        /** server's host name */
@@ -90,17 +94,36 @@ private:
 class Server : public boost::noncopyable
 {
 public:
-       Server (boost::shared_ptr<Log> log);
+       Server (boost::shared_ptr<Log> log, bool verbose);
 
        void run (int num_threads);
 
 private:
        void worker_thread ();
        int process (boost::shared_ptr<Socket> socket);
+       void broadcast_thread ();
+       void broadcast_received ();
 
        std::vector<boost::thread *> _worker_threads;
        std::list<boost::shared_ptr<Socket> > _queue;
        boost::mutex _worker_mutex;
        boost::condition _worker_condition;
        boost::shared_ptr<Log> _log;
+       bool _verbose;
+
+       struct Broadcast {
+
+               Broadcast ()
+                       : thread (0)
+                       , socket (0)
+               {}
+               
+               boost::thread* thread;
+               boost::asio::ip::udp::socket* socket;
+               char buffer[64];
+               boost::asio::ip::udp::endpoint send_endpoint;
+               
+       } _broadcast;
 };
+
+#endif