Initial commit
This commit is contained in:
31
src/server/server.cpp
Executable file
31
src/server/server.cpp
Executable file
@@ -0,0 +1,31 @@
|
||||
#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());
|
||||
}
|
||||
Reference in New Issue
Block a user