Cade Royal CSCE 412 Project 3
Loading...
Searching...
No Matches
WebServer.h
Go to the documentation of this file.
1
10#ifndef WEBSERVER_H
11#define WEBSERVER_H
12
13#include <string>
14#include <thread>
15#include <mutex>
16#include <condition_variable>
17#include "Request.h"
18
27class WebServer {
28public:
34 WebServer(std::mutex& coutMutex_);
35
39 ~WebServer();
40
44 void start();
45
51 void assignRequest(const Request& req);
52
56 void stop();
57
63 bool isRunning();
64
70 bool hasRequest();
71
75 void printDetails();
76
77private:
78 std::string ipAddress_;
79 std::thread serverThread_;
80 bool isRunning_;
81 std::mutex mtx_;
82 std::condition_variable cv_;
83 Request currentRequest_;
84 bool hasRequest_;
85 std::mutex& coutMutex_;
90 void run();
91};
92
93#endif // WEBSERVER_H
94
Defines the Request class, representing a network request.
A class to represent a network request.
Definition Request.h:25
A class that represents a web server handling HTTP requests.
Definition WebServer.h:27
~WebServer()
Destructor to clean up resources used by the WebServer.
Definition WebServer.cpp:53
void assignRequest(const Request &req)
Assigns a request to the web server for processing.
Definition WebServer.cpp:75
bool hasRequest()
Checks if the server currently has a request assigned.
Definition WebServer.cpp:141
void start()
Starts the web server in a separate thread.
Definition WebServer.cpp:64
void printDetails()
Prints details about the web server's status and configuration.
Definition WebServer.cpp:150
void stop()
Stops the web server and joins the server thread.
Definition WebServer.cpp:87
bool isRunning()
Checks if the web server is currently running.
Definition WebServer.cpp:132
std::mutex coutMutex_
Definition main.cpp:17