Utils/Logger: BUGFIX: Include local auto_unit_test header
[senf.git] / Console / Server.hh
index 52925d0..1974a74 100644 (file)
@@ -35,8 +35,6 @@
 #include "../Socket/Protocols/INet/TCPSocketHandle.hh"
 #include "../Socket/ServerSocketHandle.hh"
 #include "../Scheduler/Scheduler.hh"
-#include "../Scheduler/Binding.hh"
-#include "../Scheduler/Timer.hh"
 #include "../Scheduler/ReadHelper.hh"
 #include "Parse.hh"
 #include "Executor.hh"
@@ -56,7 +54,6 @@ namespace console {
 
         This class provides an interactive console TCP server.
 
-        \todo Add interactivity detection using timeout
         \idea To support blocking commands, we could give the Client 'suspend()' and 'resume()'
             members. suspend() would probably throw some kind of exception to transfer control back
             to the Client instance. on resume(), the command would be called again, maybe setting
@@ -64,15 +61,11 @@ namespace console {
             our own little host-name cache. When the name is not found, we ask the resolver to
             resolve it and call 'resume' when the name is found. Since it is in the cache now, the
             command will now complete.
-        
-        \implementation We do \e not provide an \c instance() member so we can easily later extend
-            the server to allow registering more than one instance, e.g. with each instance on a
-            differently firewalled port and with different security restrictions.
-        
+
         \ingroup console_access
       */
     class Server
-        : boost::noncopyable
+        : public senf::intrusive_refcount
     {
         SENF_LOG_CLASS_AREA();
         SENF_LOG_DEFAULT_LEVEL( senf::log::NOTICE );
@@ -86,8 +79,6 @@ namespace console {
 
         ///////////////////////////////////////////////////////////////////////////
 
-        ~Server();
-
         static Server & start(senf::INet4SocketAddress const & address);
                                         ///< Start server on given IPv4 address/port
         static Server & start(senf::INet6SocketAddress const & address);
@@ -124,21 +115,21 @@ namespace console {
                                              opened. */
 
         void stop();                    ///< Stop the server
-                                        /**< All clients will be closed */
+                                        /**< All clients will be closed 
+                                             \warning The Server instance itself will be deleted */
 
-        
     protected:
 
     private:
         Server(ServerHandle handle);
 
         static Server & start(ServerHandle handle);
-        static boost::scoped_ptr<Server> & instancePtr();
 
-        void newClient(Scheduler::EventId event);
+        void newClient(int event);
         void removeClient(Client & client);
         
         ServerHandle handle_;
+        scheduler::FdEvent event_;
         DirectoryNode::ptr root_;
         Mode mode_;
         
@@ -202,8 +193,8 @@ namespace console {
         
         Server & server_;
         ClientHandle handle_;
-        SchedulerBinding binding_;
-        SchedulerTimer timer_;
+        scheduler::FdEvent readevent_;
+        scheduler::TimerEvent timer_;
         CommandParser parser_;
         Executor executor_;
         std::string name_;