Renamed HLAPI to VoidNet_HL and VoidNet to VoidNet_LL

This commit is contained in:
TheDoctor
2019-10-15 19:16:52 +01:00
parent 0b48708667
commit b671953f40
52 changed files with 0 additions and 0 deletions

View File

@ -0,0 +1,33 @@
#include "HLAPI/TcpServer.hpp"
#include "HLAPI/TcpConnection.hpp"
#include "VoidNet/TcpSocketBuilder.hpp"
#include "VoidNet/TcpClient.hpp"
#include "HLAPI/TcpConnectionHandler.hpp"
namespace std::net
{
TcpServer::TcpServer(uint32_t max_connections, uint16_t port)
: m_maxConnections(max_connections)
, m_port(port)
, m_run(false)
{
if (port == 0)
throw std::invalid_argument("TcpServer::TcpServer()");
listener = std::shared_ptr<TcpListener>(TcpSocketBuilder().AsReusable().Bind(IPAddress(0, 0, 0, 0, port)).Listening().BuildListener().release());
m_connectionHandler = std::make_shared<std::net::TcpConnectionHandler>(listener);
m_connectionHandler->SetMaxConnections(max_connections);
}
void TcpServer::Start()
{
m_run = true;
m_connectionHandler->Start();
}
void TcpServer::Stop()
{
m_run.exchange(false);
}
}