]> git.tdb.fi Git - libs/net.git/blobdiff - source/http/server.h
Add a dynamic receiver class for more flexible packet handling
[libs/net.git] / source / http / server.h
index 4835de039c87b46781499a52e54cb901782b5188..8665fa3c88f5c0777f25e11ce578f23d2a8d67ff 100644 (file)
@@ -1,8 +1,8 @@
 #ifndef MSP_HTTP_SERVER_H_
 #define MSP_HTTP_SERVER_H_
 
-#include <msp/core/refptr.h>
 #include <msp/io/eventdispatcher.h>
+#include <msp/net/mspnet_api.h>
 #include <msp/net/streamserversocket.h>
 #include <msp/time/timedelta.h>
 
@@ -12,7 +12,7 @@ namespace Http {
 class Request;
 class Response;
 
-class Server
+class MSPNET_API Server
 {
 public:
        sigc::signal<void, const Request &, Response &> signal_request;
@@ -20,22 +20,21 @@ public:
 private:
        struct Client
        {
-               RefPtr<Net::StreamSocket> sock;
+               std::unique_ptr<Net::StreamSocket> sock;
                std::string in_buf;
-               Request *request;
-               Response *response;
-               bool keepalive;
-               bool async;
-               bool stale;
-
-               Client(RefPtr<Net::StreamSocket>);
-               ~Client();
+               std::unique_ptr<Request> request;
+               std::unique_ptr<Response> response;
+               bool keepalive = false;
+               bool async = false;
+               bool stale = false;
+
+               Client(std::unique_ptr<Net::StreamSocket>);
        };
 
        Net::StreamServerSocket sock;
        std::list<Client> clients;
        std::map<Response *, Client *> responses;
-       IO::EventDispatcher *event_disp;
+       IO::EventDispatcher *event_disp = nullptr;
 
 public:
        Server();