]> git.sesse.net Git - cubemap/blobdiff - server.h
Make a useful constructor for Client.
[cubemap] / server.h
index 271732b55e5a848a232c73fd967cefa4fa26448c..6311c68095c6ef9558bbb7518fb5e8d9a2caae02 100644 (file)
--- a/server.h
+++ b/server.h
@@ -13,6 +13,9 @@
 #define MAX_CLIENT_REQUEST 16384
 
 struct Client {
+       Client() {}
+       Client(int sock);
+
        // The file descriptor associated with this socket.
        int sock;
 
@@ -21,9 +24,9 @@ struct Client {
 
        // The HTTP request, as sent by the client. If we are in READING_REQUEST,
        // this might not be finished.
-       std::string client_request;
+       std::string request;
 
-       // What stream we're connecting to; parsed from client_request.
+       // What stream we're connecting to; parsed from <request>.
        // Not relevant for READING_REQUEST.
        std::string stream_id;
 
@@ -57,14 +60,24 @@ public:
 
        // Start a new thread that handles clients.
        void run();
+
+       // Stop the thread.
+       void stop();
+
        void add_client(int sock);
        void add_stream(const std::string &stream_id);
        void set_header(const std::string &stream_id, const std::string &header);
        void add_data(const std::string &stream_id, const char *data, size_t bytes);
 
 private:
+       pthread_t worker_thread;
+
+       // All variables below this line are protected by the mutex.
        pthread_mutex_t mutex;
 
+       // If the thread should stop or not.
+       bool should_stop;       
+
        // Map from stream ID to stream.
        std::map<std::string, Stream> streams;