implement thread names in debug mode

This commit is contained in:
Lion Kortlepel
2021-03-30 00:30:24 +02:00
parent 940a39ed4e
commit 3094d382ff
9 changed files with 61 additions and 36 deletions

View File

@@ -2,8 +2,8 @@
#include "Client.h"
#include <CustomAssert.h>
#include <Http.h>
#include <cstring>
#include <array>
#include <cstring>
TNetwork::TNetwork(TServer& Server, TPPSMonitor& PPSMonitor, TResourceManager& ResourceManager)
: mServer(Server)
@@ -30,6 +30,7 @@ TNetwork::TNetwork(TServer& Server, TPPSMonitor& PPSMonitor, TResourceManager& R
}
void TNetwork::UDPServerMain() {
RegisterThread("UDPServer");
#ifdef WIN32
WSADATA data;
if (WSAStartup(514, &data)) {
@@ -99,6 +100,7 @@ void TNetwork::UDPServerMain() {
}
void TNetwork::TCPServerMain() {
RegisterThread("TCPServer");
#ifdef WIN32
WSADATA wsaData;
if (WSAStartup(514, &wsaData)) {
@@ -201,6 +203,7 @@ void TNetwork::TCPServerMain() {
namespace json = rapidjson;
void TNetwork::Identify(SOCKET TCPSock) {
RegisterThreadAuto();
char Code;
if (recv(TCPSock, &Code, 1, 0) != 1) {
CloseSocketProper(TCPSock);
@@ -293,6 +296,7 @@ void TNetwork::Authentication(SOCKET TCPSock) {
return;
}
RegisterThread(Client->GetName());
debug("Name -> " + Client->GetName() + ", Guest -> " + std::to_string(Client->IsGuest()) + ", Roles -> " + Client->GetRoles());
debug("There are " + std::to_string(mServer.ClientCount()) + " known clients");
mServer.ForEachClient([&](const std::weak_ptr<TClient>& ClientPtr) -> bool {