31 lines
717 B
C++
Executable File
31 lines
717 B
C++
Executable File
#include "../logger.hpp"
|
|
#include "configuration.hpp"
|
|
#include "server.hpp"
|
|
#include <sstream>
|
|
#include <stdexcept>
|
|
|
|
void HttpServer::Execute()
|
|
{
|
|
while(isOpen)
|
|
{
|
|
try
|
|
{
|
|
Connection newConnection = listeningSocket.AcceptNextConnection();
|
|
connectionOperator.HandleNewConnection(newConnection);
|
|
}
|
|
catch (std::runtime_error & e)
|
|
{
|
|
Logger::GetInstance().Info("Connection dropped on accept");
|
|
}
|
|
}
|
|
}
|
|
|
|
HttpServer::HttpServer()
|
|
: listeningSocket(ServerConfiguration::GetInstance().GetPort()),
|
|
connectionOperator(),
|
|
isOpen(true)
|
|
{
|
|
std::stringstream ss;
|
|
ss << "Listening on port " << ServerConfiguration::GetInstance().GetPort();
|
|
Logger::GetInstance().Info(ss.str());
|
|
} |