mirror of
https://github.com/BeamMP/BeamMP-Server.git
synced 2026-04-11 18:26:20 +00:00
Support of 1Gps+ internet
This commit is contained in:
@@ -25,9 +25,6 @@ std::string GetClientInfo(const std::string& PK) {
|
||||
Client* CreateClient(SOCKET TCPSock) {
|
||||
auto* c = new Client;
|
||||
c->SetTCPSock(TCPSock);
|
||||
//c->SetRoles(Roles);
|
||||
//c->isGuest = Guest;
|
||||
//c->SetName(Name);
|
||||
return c;
|
||||
}
|
||||
|
||||
@@ -38,7 +35,7 @@ void ClientKick(Client* c, const std::string& R){
|
||||
}
|
||||
|
||||
|
||||
void Identification(SOCKET TCPSock) {
|
||||
void Authentication(SOCKET TCPSock) {
|
||||
DebugPrintTID();
|
||||
auto* c = CreateClient(TCPSock);
|
||||
|
||||
@@ -84,7 +81,7 @@ void Identification(SOCKET TCPSock) {
|
||||
debug("Name -> " + c->GetName() + ", Guest -> " + std::to_string(c->isGuest) + ", Roles -> " + c->GetRoles());
|
||||
for (auto& Cl : CI->Clients) {
|
||||
if (Cl != nullptr) {
|
||||
if (Cl->GetName() == c->GetName()) {
|
||||
if (Cl->GetName() == c->GetName() && Cl->isGuest == c->isGuest) {
|
||||
info("Old client (" +Cl->GetName()+ ") kicked: Reconnecting");
|
||||
CloseSocketProper(Cl->GetTCPSock());
|
||||
Cl->SetStatus(-2);
|
||||
@@ -92,26 +89,58 @@ void Identification(SOCKET TCPSock) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
auto arg = std::make_unique<LuaArg>(LuaArg{{c->GetName(),c->GetRoles(),c->isGuest}});
|
||||
int Res = TriggerLuaEvent("onPlayerAuth",false,nullptr, std::move(arg), true);
|
||||
if(Res){
|
||||
std::any Res = TriggerLuaEvent("onPlayerAuth",false,nullptr, std::move(arg), true);
|
||||
std::string Type = Res.type().name();
|
||||
if(Type.find("int") != std::string::npos && std::any_cast<int>(Res)){
|
||||
ClientKick(c,"you are not allowed on the server!");
|
||||
return;
|
||||
}else if(Type.find("string") != std::string::npos){
|
||||
ClientKick(c,std::any_cast<std::string>(Res));
|
||||
return;
|
||||
}
|
||||
if (CI->Size() < MaxPlayers) {
|
||||
info("Identification success");
|
||||
Client& Client = *c;
|
||||
CI->AddClient(std::move(c));
|
||||
InitClient(&Client);
|
||||
TCPClient(&Client);
|
||||
} else ClientKick(c,"Server full!");
|
||||
}
|
||||
|
||||
void HandleDownload(SOCKET TCPSock){
|
||||
char D;
|
||||
if(recv(TCPSock,&D,1,0) != 1){
|
||||
CloseSocketProper(TCPSock);
|
||||
return;
|
||||
}
|
||||
auto ID = uint8_t(D);
|
||||
for(auto& c : CI->Clients){
|
||||
if(c->GetID() == ID){
|
||||
c->SetDownSock(TCPSock);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Identify(SOCKET TCPSock){
|
||||
char Code;
|
||||
if(recv(TCPSock,&Code,1,0) != 1) {
|
||||
CloseSocketProper(TCPSock);
|
||||
return;
|
||||
}
|
||||
if(Code == 'C'){
|
||||
Authentication(TCPSock);
|
||||
}else if(Code == 'D'){
|
||||
HandleDownload(TCPSock);
|
||||
}else CloseSocketProper(TCPSock);
|
||||
}
|
||||
|
||||
void TCPServerMain() {
|
||||
DebugPrintTID();
|
||||
#ifdef WIN32
|
||||
WSADATA wsaData;
|
||||
if (WSAStartup(514, &wsaData)) {
|
||||
error(Sec("Can't start Winsock!"));
|
||||
error("Can't start Winsock!");
|
||||
return;
|
||||
}
|
||||
SOCKET client, Listener = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
|
||||
@@ -120,30 +149,30 @@ void TCPServerMain() {
|
||||
addr.sin_family = AF_INET;
|
||||
addr.sin_port = htons(Port);
|
||||
if (bind(Listener, (sockaddr*)&addr, sizeof(addr)) == SOCKET_ERROR) {
|
||||
error(Sec("Can't bind socket! ") + std::to_string(WSAGetLastError()));
|
||||
error("Can't bind socket! " + std::to_string(WSAGetLastError()));
|
||||
std::this_thread::sleep_for(std::chrono::seconds(5));
|
||||
_Exit(-1);
|
||||
}
|
||||
if (Listener == -1) {
|
||||
error(Sec("Invalid listening socket"));
|
||||
error("Invalid listening socket");
|
||||
return;
|
||||
}
|
||||
if (listen(Listener, SOMAXCONN)) {
|
||||
error(Sec("listener failed ") + std::to_string(GetLastError()));
|
||||
error("listener failed " + std::to_string(GetLastError()));
|
||||
return;
|
||||
}
|
||||
info(Sec("Vehicle event network online"));
|
||||
info("Vehicle event network online");
|
||||
do {
|
||||
try {
|
||||
client = accept(Listener, nullptr, nullptr);
|
||||
if (client == -1) {
|
||||
warn(Sec("Got an invalid client socket on connect! Skipping..."));
|
||||
warn("Got an invalid client socket on connect! Skipping...");
|
||||
continue;
|
||||
}
|
||||
std::thread ID(Identification, client);
|
||||
std::thread ID(Identify, client);
|
||||
ID.detach();
|
||||
} catch (const std::exception& e) {
|
||||
error(Sec("fatal: ") + std::string(e.what()));
|
||||
error("fatal: " + std::string(e.what()));
|
||||
}
|
||||
} while (client);
|
||||
|
||||
|
||||
@@ -32,15 +32,23 @@ int Client::GetStatus() {
|
||||
void Client::SetUDPAddr(sockaddr_in Addr) {
|
||||
UDPADDR = Addr;
|
||||
}
|
||||
|
||||
void Client::SetDownSock(SOCKET CSock){
|
||||
SOCK[1] = CSock;
|
||||
}
|
||||
SOCKET Client::GetDownSock(){
|
||||
return SOCK[1];
|
||||
}
|
||||
sockaddr_in Client::GetUDPAddr() {
|
||||
return UDPADDR;
|
||||
}
|
||||
void Client::SetTCPSock(SOCKET CSock) {
|
||||
TCPSOCK = CSock;
|
||||
SOCK[0] = CSock;
|
||||
}
|
||||
SOCKET Client::GetTCPSock() {
|
||||
return TCPSOCK;
|
||||
return SOCK[0];
|
||||
}
|
||||
|
||||
void Client::DeleteCar(int ident) {
|
||||
for (auto& v : VehicleData) {
|
||||
if (v != nullptr && v->ID == ident) {
|
||||
|
||||
@@ -49,7 +49,8 @@ void VehicleParser(Client* c, const std::string& Pckt) {
|
||||
int CarID = c->GetOpenCarID();
|
||||
debug(c->GetName() + Sec(" created a car with ID ") + std::to_string(CarID));
|
||||
Packet = "Os:" + c->GetRoles() + ":" + c->GetName() + ":" + std::to_string(c->GetID()) + "-" + std::to_string(CarID) + Packet.substr(4);
|
||||
if (c->GetCarCount() >= MaxCars || TriggerLuaEvent(Sec("onVehicleSpawn"), false, nullptr, std::make_unique<LuaArg>(LuaArg { { c->GetID(), CarID, Packet.substr(3) } }), true)) {
|
||||
auto Res = TriggerLuaEvent(Sec("onVehicleSpawn"), false, nullptr, std::make_unique<LuaArg>(LuaArg { { c->GetID(), CarID, Packet.substr(3) } }), true);
|
||||
if (c->GetCarCount() >= MaxCars || std::any_cast<int>(Res)) {
|
||||
Respond(c, Packet, true);
|
||||
std::string Destroy = "Od:" + std::to_string(c->GetID()) + "-" + std::to_string(CarID);
|
||||
Respond(c, Destroy, true);
|
||||
@@ -71,9 +72,10 @@ void VehicleParser(Client* c, const std::string& Pckt) {
|
||||
VID = stoi(vid);
|
||||
}
|
||||
if (PID != -1 && VID != -1 && PID == c->GetID()) {
|
||||
if (!TriggerLuaEvent(Sec("onVehicleEdited"), false, nullptr,
|
||||
std::unique_ptr<LuaArg>(new LuaArg { { c->GetID(), VID, Packet.substr(3) } }),
|
||||
true)) {
|
||||
auto Res = TriggerLuaEvent(Sec("onVehicleEdited"), false, nullptr,
|
||||
std::make_unique<LuaArg>(LuaArg { { c->GetID(), VID, Packet.substr(3) } }),
|
||||
true);
|
||||
if (!std::any_cast<int>(Res)) {
|
||||
SendToAll(c, Packet, false, true);
|
||||
Apply(c, VID, Packet);
|
||||
} else {
|
||||
@@ -96,7 +98,7 @@ void VehicleParser(Client* c, const std::string& Pckt) {
|
||||
if (PID != -1 && VID != -1 && PID == c->GetID()) {
|
||||
SendToAll(nullptr, Packet, true, true);
|
||||
TriggerLuaEvent(Sec("onVehicleDeleted"), false, nullptr,
|
||||
std::unique_ptr<LuaArg>(new LuaArg { { c->GetID(), VID } }), false);
|
||||
std::make_unique<LuaArg>(LuaArg { { c->GetID(), VID } }), false);
|
||||
c->DeleteCar(VID);
|
||||
debug(c->GetName() + Sec(" deleted car with ID ") + std::to_string(VID));
|
||||
}
|
||||
@@ -128,7 +130,7 @@ void SyncClient(Client* c) {
|
||||
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||
Respond(c, Sec("Sn") + c->GetName(), true);
|
||||
SendToAll(c, Sec("JWelcome ") + c->GetName() + "!", false, true);
|
||||
TriggerLuaEvent(Sec("onPlayerJoin"), false, nullptr, std::unique_ptr<LuaArg>(new LuaArg { { c->GetID() } }), false);
|
||||
TriggerLuaEvent(Sec("onPlayerJoin"), false, nullptr, std::make_unique<LuaArg>(LuaArg { { c->GetID() } }), false);
|
||||
for (auto& client : CI->Clients) {
|
||||
if (client != nullptr) {
|
||||
if (client.get() != c) {
|
||||
@@ -166,7 +168,7 @@ void HandleEvent(Client* c, const std::string& Data) {
|
||||
Name = t;
|
||||
break;
|
||||
case 2:
|
||||
TriggerLuaEvent(Name, false, nullptr, std::unique_ptr<LuaArg>(new LuaArg { { c->GetID(), t } }), false);
|
||||
TriggerLuaEvent(Name, false, nullptr, std::make_unique<LuaArg>(LuaArg { { c->GetID(), t } }), false);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -181,6 +183,7 @@ void GlobalParser(Client* c, const std::string& Pack) {
|
||||
Assert(c);
|
||||
if (Pack.empty() || c == nullptr)
|
||||
return;
|
||||
std::any Res;
|
||||
std::string Packet = Pack.substr(0, strlen(Pack.c_str()));
|
||||
std::string pct;
|
||||
char Code = Packet.at(0);
|
||||
@@ -192,11 +195,10 @@ void GlobalParser(Client* c, const std::string& Pack) {
|
||||
return;
|
||||
}
|
||||
switch (Code) {
|
||||
case 'P': // initial connection
|
||||
case 'H': // initial connection
|
||||
#ifdef DEBUG
|
||||
debug(std::string(Sec("got 'P' packet: '")) + Pack + Sec("' (") + std::to_string(Packet.size()) + Sec(")"));
|
||||
debug(std::string("got 'H' packet: '") + Pack + "' (" + std::to_string(Packet.size()) + ")");
|
||||
#endif
|
||||
Respond(c, Sec("P") + std::to_string(c->GetID()), true);
|
||||
SyncClient(c);
|
||||
return;
|
||||
case 'p':
|
||||
@@ -221,10 +223,9 @@ void GlobalParser(Client* c, const std::string& Pack) {
|
||||
#endif
|
||||
if (Packet.length() < 4 || Packet.find(':', 3) == std::string::npos)
|
||||
break;
|
||||
if (TriggerLuaEvent(Sec("onChatMessage"), false, nullptr,
|
||||
std::unique_ptr<LuaArg>(new LuaArg {
|
||||
{ c->GetID(), c->GetName(), Packet.substr(Packet.find(':', 3) + 1) } }),
|
||||
true))
|
||||
Res = TriggerLuaEvent("onChatMessage", false, nullptr,std::make_unique<LuaArg>(LuaArg {
|
||||
{ c->GetID(), c->GetName(), Packet.substr(Packet.find(':', 3) + 1) } }),true);
|
||||
if (std::any_cast<int>(Res))
|
||||
break;
|
||||
SendToAll(nullptr, Packet, true, true);
|
||||
return;
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
///
|
||||
/// Created by Anonymous275 on 8/1/2020
|
||||
///
|
||||
#include "Client.hpp"
|
||||
|
||||
#include <memory>
|
||||
#include "Logger.h"
|
||||
#include "Lua/LuaSystem.hpp"
|
||||
#include "Network.h"
|
||||
#include "Security/Enc.h"
|
||||
#include "Client.hpp"
|
||||
#include "UnixCompat.h"
|
||||
#include "Settings.h"
|
||||
#include "Network.h"
|
||||
#include "Logger.h"
|
||||
#include <memory>
|
||||
|
||||
|
||||
|
||||
int OpenID() {
|
||||
int ID = 0;
|
||||
bool found;
|
||||
@@ -83,18 +85,19 @@ void OnDisconnect(Client* c, bool kicked) {
|
||||
SendToAll(c, Packet, false, true);
|
||||
Packet.clear();
|
||||
TriggerLuaEvent(Sec("onPlayerDisconnect"), false, nullptr, std::make_unique<LuaArg>(LuaArg { { c->GetID() } }), false);
|
||||
if(c->GetTCPSock())CloseSocketProper(c->GetTCPSock());
|
||||
if(c->GetDownSock())CloseSocketProper(c->GetDownSock());
|
||||
CI->RemoveClient(c); ///Removes the Client from existence
|
||||
}
|
||||
void OnConnect(Client* c) {
|
||||
Assert(c);
|
||||
info(Sec("Client connected"));
|
||||
info("Client connected");
|
||||
c->SetID(OpenID());
|
||||
info(Sec("Assigned ID ") + std::to_string(c->GetID()) + Sec(" to ") + c->GetName());
|
||||
TriggerLuaEvent(Sec("onPlayerConnecting"), false, nullptr, std::make_unique<LuaArg>(LuaArg { { c->GetID() } }), false);
|
||||
info("Assigned ID " + std::to_string(c->GetID()) +" to " + c->GetName());
|
||||
TriggerLuaEvent("onPlayerConnecting", false, nullptr, std::make_unique<LuaArg>(LuaArg { { c->GetID() } }), false);
|
||||
SyncResources(c);
|
||||
if (c->GetStatus() < 0)
|
||||
return;
|
||||
if (c->GetStatus() < 0)return;
|
||||
Respond(c, "M" + MapName, true); //Send the Map on connect
|
||||
info(c->GetName() + Sec(" : Connected"));
|
||||
TriggerLuaEvent(Sec("onPlayerJoining"), false, nullptr, std::make_unique<LuaArg>(LuaArg { { c->GetID() } }), false);
|
||||
info(c->GetName() +" : Connected");
|
||||
TriggerLuaEvent("onPlayerJoining", false, nullptr, std::make_unique<LuaArg>(LuaArg { { c->GetID() } }), false);
|
||||
}
|
||||
|
||||
@@ -5,48 +5,97 @@
|
||||
#include "UnixCompat.h"
|
||||
#include "Settings.h"
|
||||
#include "Client.hpp"
|
||||
#include <filesystem>
|
||||
#include "Network.h"
|
||||
#include "Logger.h"
|
||||
#include <fstream>
|
||||
#ifdef __linux
|
||||
// we need this for `struct stat`
|
||||
#include <sys/stat.h>
|
||||
#endif // __linux
|
||||
|
||||
void SendFile(Client* c, const std::string& Name) {
|
||||
Assert(c);
|
||||
info(c->GetName() + " requesting : " + Name.substr(Name.find_last_of('/')));
|
||||
struct stat Info { };
|
||||
if (stat(Name.c_str(), &Info) != 0) {
|
||||
TCPSend(c, "Cannot Open");
|
||||
return;
|
||||
}
|
||||
bool TCPSendRaw(SOCKET C, char* Data, int32_t Size){
|
||||
int64_t Sent = 0, Temp;
|
||||
do {
|
||||
Temp = send(C, &Data[Sent], int(Size - Sent), 0);
|
||||
if(Temp < 1) {
|
||||
info("Socket Closed! " + std::to_string(C));
|
||||
CloseSocketProper(C);
|
||||
return false;
|
||||
}
|
||||
Sent += Temp;
|
||||
} while (Sent < Size);
|
||||
return true;
|
||||
}
|
||||
|
||||
void SplitLoad(Client*c,int64_t Sent,int64_t Size, bool D,const std::string& Name){
|
||||
std::ifstream f(Name.c_str(), std::ios::binary);
|
||||
f.seekg(0, std::ios_base::end);
|
||||
std::streampos fileSize = f.tellg();
|
||||
auto Size = size_t(fileSize);
|
||||
size_t Sent = 0;
|
||||
size_t Diff;
|
||||
int64_t Split = 64000;
|
||||
int32_t Split = 0x7735940; //125MB
|
||||
int64_t Diff;
|
||||
char* Data;
|
||||
if(Size > Split)Data = new char[Split];
|
||||
else Data = new char[Size];
|
||||
SOCKET TCPSock = c->GetTCPSock();
|
||||
if(D){
|
||||
TCPSock = c->GetDownSock();
|
||||
}
|
||||
info("Split load Socket " + std::to_string(TCPSock));
|
||||
while (c->GetStatus() > -1 && Sent < Size) {
|
||||
Diff = Size - Sent;
|
||||
if (Diff > size_t(Split)) {
|
||||
std::string Data(size_t(Split), 0);
|
||||
f.seekg(int64_t(Sent), std::ios_base::beg);
|
||||
f.read(&Data[0], Split);
|
||||
TCPSend(c, Data);
|
||||
Sent += size_t(Split);
|
||||
if (Diff > Split) {
|
||||
f.seekg(Sent, std::ios_base::beg);
|
||||
f.read(Data, Split);
|
||||
if(!TCPSendRaw(TCPSock, Data, Split)){
|
||||
if(c->GetStatus() > -1)c->SetStatus(-1);
|
||||
break;
|
||||
}
|
||||
Sent += Split;
|
||||
} else {
|
||||
std::string Data(Diff, 0);
|
||||
f.seekg(int64_t(Sent), std::ios_base::beg);
|
||||
f.read(&Data[0], int64_t(Diff));
|
||||
TCPSend(c, Data);
|
||||
f.seekg(Sent, std::ios_base::beg);
|
||||
f.read(Data, Diff);
|
||||
if(!TCPSendRaw(TCPSock, Data, int32_t(Diff))){
|
||||
if(c->GetStatus() > -1)c->SetStatus(-1);
|
||||
break;
|
||||
}
|
||||
Sent += Diff;
|
||||
}
|
||||
}
|
||||
delete[] Data;
|
||||
f.close();
|
||||
}
|
||||
|
||||
|
||||
void SendFile(Client*c, const std::string& Name) {
|
||||
Assert(c);
|
||||
info(c->GetName() + " requesting : " + Name.substr(Name.find_last_of('/')));
|
||||
|
||||
if(!std::filesystem::exists(Name)) {
|
||||
TCPSend(c, "CO");
|
||||
warn("File " + Name + " could not be accessed!");
|
||||
return;
|
||||
}else TCPSend(c, "AG");
|
||||
|
||||
///Wait for connections
|
||||
int T = 0;
|
||||
while(c->GetDownSock() < 1 && T < 30){
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
||||
T++;
|
||||
}
|
||||
|
||||
|
||||
if(c->GetDownSock() < 1){
|
||||
error("Client doesn't have a download socket!");
|
||||
if(c->GetStatus() > -1)c->SetStatus(-1);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
int64_t Size = std::filesystem::file_size(Name), MSize = Size/2;
|
||||
|
||||
std::thread Dt(SplitLoad,c,0,MSize,false,Name);
|
||||
Dt.detach();
|
||||
|
||||
SplitLoad(c,MSize,Size,true,Name);
|
||||
|
||||
if(Dt.joinable())Dt.join();
|
||||
}
|
||||
|
||||
void Parse(Client* c, const std::string& Packet) {
|
||||
Assert(c);
|
||||
if (c == nullptr || Packet.empty())
|
||||
@@ -62,8 +111,7 @@ void Parse(Client* c, const std::string& Packet) {
|
||||
if (SubCode == 'R') {
|
||||
debug(Sec("Sending Mod Info"));
|
||||
std::string ToSend = FileList + FileSizes;
|
||||
if (ToSend.empty())
|
||||
ToSend = "-";
|
||||
if (ToSend.empty())ToSend = "-";
|
||||
TCPSend(c, ToSend);
|
||||
}
|
||||
return;
|
||||
@@ -75,16 +123,20 @@ void Parse(Client* c, const std::string& Packet) {
|
||||
void SyncResources(Client* c) {
|
||||
Assert(c);
|
||||
if (c == nullptr)return;
|
||||
#ifndef DEBUG
|
||||
try {
|
||||
TCPSend(c, "WS");
|
||||
#endif
|
||||
TCPSend(c, "P" + std::to_string(c->GetID()));
|
||||
std::string Data;
|
||||
while (c->GetStatus() > -1){
|
||||
Data = TCPRcv(c);
|
||||
if(Data == "Done")break;
|
||||
Parse(c, Data);
|
||||
}
|
||||
#ifndef DEBUG
|
||||
} catch (std::exception& e) {
|
||||
except("Exception! : " + std::string(e.what()));
|
||||
c->SetStatus(-1);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1,20 +1,17 @@
|
||||
///
|
||||
/// Created by Anonymous275 on 8/1/2020
|
||||
///
|
||||
#include "Compressor.h"
|
||||
#include "Logger.h"
|
||||
#include "Network.h"
|
||||
#include "Security/Enc.h"
|
||||
#include "UnixCompat.h"
|
||||
#include "Compressor.h"
|
||||
#include "Network.h"
|
||||
#include "Logger.h"
|
||||
#include <thread>
|
||||
|
||||
bool TCPSend(Client* c, const std::string& Data) {
|
||||
Assert(c);
|
||||
if (c == nullptr)
|
||||
return false;
|
||||
// Size is BIG ENDIAN now, use only for header!
|
||||
//auto Size = htonl(int32_t(Data.size()));
|
||||
///TODO : BIG ENDIAN for other OS
|
||||
if (c == nullptr)return false;
|
||||
|
||||
int32_t Size, Sent, Temp;
|
||||
std::string Send(4, 0);
|
||||
Size = int32_t(Data.size());
|
||||
@@ -31,7 +28,6 @@ bool TCPSend(Client* c, const std::string& Data) {
|
||||
} else if (Temp < 0) {
|
||||
if (c->GetStatus() > -1)
|
||||
c->SetStatus(-1);
|
||||
// info(Sec("Closing socket, Temp < 0"));
|
||||
CloseSocketProper(c->GetTCPSock());
|
||||
return false;
|
||||
}
|
||||
@@ -43,7 +39,7 @@ bool TCPSend(Client* c, const std::string& Data) {
|
||||
bool CheckBytes(Client* c, int32_t BytesRcv) {
|
||||
Assert(c);
|
||||
if (BytesRcv == 0) {
|
||||
debug(Sec("(TCP) Connection closing..."));
|
||||
debug("(TCP) Connection closing...");
|
||||
if (c->GetStatus() > -1)
|
||||
c->SetStatus(-1);
|
||||
return false;
|
||||
@@ -122,7 +118,7 @@ std::string TCPRcv(Client* c) {
|
||||
}
|
||||
|
||||
void TCPClient(Client* c) {
|
||||
DebugPrintTIDInternal(Sec("Client(") + c->GetName() + Sec(")"), true);
|
||||
DebugPrintTIDInternal("Client(" + c->GetName() + ")", true);
|
||||
Assert(c);
|
||||
if (c->GetTCPSock() == -1) {
|
||||
CI->RemoveClient(c);
|
||||
@@ -134,7 +130,3 @@ void TCPClient(Client* c) {
|
||||
}
|
||||
OnDisconnect(c, c->GetStatus() == -2);
|
||||
}
|
||||
void InitClient(Client* c) {
|
||||
std::thread NewClient(TCPClient, c);
|
||||
NewClient.detach();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user