X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Console%2FServer.ih;h=eb6ab722c53221072d2cb0a2ea6b5f89454b0f26;hb=18ebf1e9edb34f1aa8a32173275421a5d54400f7;hp=d25aed3601cef3701573532cc5cc137bd99e2f54;hpb=826e50343096b75247521f6593cb78eb8c01615b;p=senf.git diff --git a/Console/Server.ih b/Console/Server.ih index d25aed3..eb6ab72 100644 --- a/Console/Server.ih +++ b/Console/Server.ih @@ -27,19 +27,8 @@ #define IH_Server_ 1 // Custom includes -#include -#include -#include -#include -#include +#include #include -#include "../Utils/intrusive_refcount.hh" -#include "../Socket/Protocols/INet/TCPSocketHandle.hh" -#include "../Socket/ServerSocketHandle.hh" -#include "../Scheduler/Scheduler.hh" -#include "../Scheduler/ReadHelper.hh" -#include "Parse.hh" -#include "Executor.hh" ///////////////////////////////ih.p//////////////////////////////////////// @@ -47,77 +36,28 @@ namespace senf { namespace console { namespace detail { - class Client; + /** \brief Internal: Nonblocking boost::iostreams::sink - /** \brief - */ - class Server - : boost::noncopyable - { - SENF_LOG_CLASS_AREA(); - SENF_LOG_DEFAULT_LEVEL( senf::log::NOTICE ); - public: - /////////////////////////////////////////////////////////////////////////// - // Types - - typedef senf::ServerSocketHandle< - senf::MakeSocketPolicy< senf::TCPv4SocketProtocol::Policy, - senf::UnspecifiedAddressingPolicy>::policy > ServerHandle; - - ~Server(); - - static void start(ServerHandle handle); - - protected: - - private: - Server(ServerHandle handle); - - void newClient(Scheduler::EventId event); - void removeClient(Client & client); - - ServerHandle handle_; - - typedef std::set< boost::intrusive_ptr > Clients; - Clients clients_; - - static boost::scoped_ptr instance_; - - friend class Client; - }; - - /** \brief + The sink discards data if the output socket would. */ - class Client - : public senf::intrusive_refcount + class NonblockingSocketSink + : public boost::iostreams::sink { - SENF_LOG_CLASS_AREA(); - SENF_LOG_DEFAULT_LEVEL( senf::log::NOTICE ); public: - typedef Server::ServerHandle::ClientSocketHandle ClientHandle; - - ~Client(); - - void stopClient(); + typedef ClientSocketHandle< + MakeSocketPolicy::policy > Handle; - protected: + NonblockingSocketSink(Handle handle); + std::streamsize write(const char * s, std::streamsize n); private: - Client(ClientHandle handle); - - void clientData(ReadHelper::ptr helper); - - ClientHandle handle_; - std::string tail_; - SingleCommandParser parser_; - Executor executor_; - - typedef boost::iostreams::stream fdostream; - fdostream out_; - - friend class Server; + Handle handle_; }; + typedef boost::iostreams::stream NonblockingSocketOStream; + }}} ///////////////////////////////ih.e////////////////////////////////////////