X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fhttp%2Fserver.h;h=8665fa3c88f5c0777f25e11ce578f23d2a8d67ff;hb=394c9a732192fce9b3b453dfdb9e92400af2a4f8;hp=29b2b45a3d4cb95ad35a529139a64834e2e3c657;hpb=09858e5a153b0667b4885da81f6f979a0bf29c36;p=libs%2Fnet.git diff --git a/source/http/server.h b/source/http/server.h index 29b2b45..8665fa3 100644 --- a/source/http/server.h +++ b/source/http/server.h @@ -1,9 +1,10 @@ #ifndef MSP_HTTP_SERVER_H_ #define MSP_HTTP_SERVER_H_ -#include #include +#include #include +#include namespace Msp { namespace Http { @@ -11,7 +12,7 @@ namespace Http { class Request; class Response; -class Server +class MSPNET_API Server { public: sigc::signal signal_request; @@ -19,31 +20,34 @@ public: private: struct Client { - RefPtr sock; + std::unique_ptr sock; std::string in_buf; - Request *request; - Response *response; - bool keepalive; - bool async; - bool stale; - - Client(RefPtr); - ~Client(); + std::unique_ptr request; + std::unique_ptr response; + bool keepalive = false; + bool async = false; + bool stale = false; + + Client(std::unique_ptr); }; Net::StreamServerSocket sock; std::list clients; std::map responses; - IO::EventDispatcher *event_disp; + IO::EventDispatcher *event_disp = nullptr; public: + Server(); Server(unsigned); ~Server(); + void listen(unsigned); unsigned get_port() const; void use_event_dispatcher(IO::EventDispatcher *); void delay_response(Response &); void submit_response(Response &); + void cancel_keepalive(Response &); + void close_connections(const Time::TimeDelta &); private: void data_available(); void client_data_available(Client &);