X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Console%2FServer.ih;h=eb6ab722c53221072d2cb0a2ea6b5f89454b0f26;hb=869df8df564cd4f4934d4cd1c1b290c2aeabbd92;hp=8355450fd76daf5341bbc91d0e9ba421c3b07d34;hpb=4fc732480d3ba33ac2589caece3b04224e51d32b;p=senf.git diff --git a/Console/Server.ih b/Console/Server.ih index 8355450..eb6ab72 100644 --- a/Console/Server.ih +++ b/Console/Server.ih @@ -27,15 +27,8 @@ #define IH_Server_ 1 // Custom includes -#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 +#include ///////////////////////////////ih.p//////////////////////////////////////// @@ -43,72 +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(); + typedef ClientSocketHandle< + MakeSocketPolicy::policy > Handle; - void stopClient(); - - 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_; - - friend class Server; + Handle handle_; }; + typedef boost::iostreams::stream NonblockingSocketOStream; + }}} ///////////////////////////////ih.e////////////////////////////////////////