]> git.tdb.fi Git - libs/net.git/blob - source/server.h
Style update: spaces around assignments
[libs/net.git] / source / server.h
1 /* $Id$
2
3 This file is part of libmsphttp
4 Copyright © 2008  Mikkosoft Productions, Mikko Rasa
5 Distributed under the LGPL
6 */
7
8 #ifndef MSP_HTTP_SERVER_H_
9 #define MSP_HTTP_SERVER_H_
10
11 #include <msp/core/refptr.h>
12 #include <msp/io/eventdispatcher.h>
13 #include <msp/net/streamlistensocket.h>
14
15 namespace Msp {
16 namespace Http {
17
18 class Request;
19 class Response;
20
21 class Server
22 {
23 public:
24         sigc::signal<void, const Request &, Response &> signal_request;
25
26 private:
27         struct Client
28         {
29                 RefPtr<Net::StreamSocket> sock;
30                 std::string in_buf;
31                 Request *request;
32                 Response *response;
33                 bool async;
34                 bool stale;
35
36                 Client(RefPtr<Net::StreamSocket>);
37                 ~Client();
38         };
39
40         Net::StreamListenSocket sock;
41         std::list<Client> clients;
42         IO::EventDispatcher *event_disp;
43
44 public:
45         Server(unsigned);
46         unsigned get_port() const;
47         void use_event_dispatcher(IO::EventDispatcher *);
48         void delay_response(Response &);
49         void submit_response(Response &);
50 private:
51         void data_available();
52         void client_data_available(Client &);
53         void client_end_of_file(Client &);
54         Client &get_client_by_response(Response &);
55 };
56
57 } // namespace Http
58 } // namespace Msp
59
60 #endif