Memory management of socket using unique_ptr, many new util functions

This commit is contained in:
2020-07-18 00:24:47 +02:00
parent b39078eedc
commit fcadff65e2
20 changed files with 365 additions and 101 deletions

View File

@@ -1,6 +1,9 @@
#include "server.h"
#include <memory>
#include <QDateTime>
#include <QTcpSocket>
#include "playclient.h"
#include "handshakingclient.h"
@@ -34,14 +37,15 @@ void Server::timeout()
{
client->keepAlive();
client->sendChatMessage();
client->randomizeStats();
client->trialDisconnect();
}
}
void Server::newConnection()
{
auto * const connection = m_server.nextPendingConnection();
auto connection = std::unique_ptr<QTcpSocket>(m_server.nextPendingConnection());
if (connection)
new HandshakingClient{*connection, *this};
new HandshakingClient{std::move(connection), *this};
//clients.push_back();
}