mirror of
https://github.com/BeamMP/BeamMP-Launcher.git
synced 2025-07-03 16:37:11 +00:00
implement string int header
This commit is contained in:
parent
7b733bf8eb
commit
137d9dd1e2
@ -190,7 +190,9 @@ void Parse(std::string Data, SOCKET CSocket) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!Data.empty() && CSocket != -1) {
|
if (!Data.empty() && CSocket != -1) {
|
||||||
int res = send(CSocket, (Data + "\n").c_str(), int(Data.size()) + 1, 0);
|
Data = std::to_string(Data.size()) + ">" + Data;
|
||||||
|
debug("Sending '" + Data + "'");
|
||||||
|
int res = send(CSocket, Data.c_str(), int(Data.size()), 0);
|
||||||
if (res < 0) {
|
if (res < 0) {
|
||||||
debug("(Core) send failed with error: " + std::to_string(WSAGetLastError()));
|
debug("(Core) send failed with error: " + std::to_string(WSAGetLastError()));
|
||||||
}
|
}
|
||||||
|
@ -63,6 +63,8 @@ void GameSend(std::string_view Data) {
|
|||||||
return;
|
return;
|
||||||
int32_t Size, Temp, Sent;
|
int32_t Size, Temp, Sent;
|
||||||
Size = int32_t(Data.size());
|
Size = int32_t(Data.size());
|
||||||
|
auto SizeStr = std::to_string(Size) + ">";
|
||||||
|
send(CSocket, SizeStr.c_str(), SizeStr.size(), 0);
|
||||||
Sent = 0;
|
Sent = 0;
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if (Size > 1000) {
|
if (Size > 1000) {
|
||||||
@ -78,10 +80,10 @@ void GameSend(std::string_view Data) {
|
|||||||
Sent += Temp;
|
Sent += Temp;
|
||||||
} while (Sent < Size);
|
} while (Sent < Size);
|
||||||
// send separately to avoid an allocation for += "\n"
|
// send separately to avoid an allocation for += "\n"
|
||||||
Temp = send(CSocket, "\n", 1, 0);
|
/*Temp = send(CSocket, "\n", 1, 0);
|
||||||
if (!CheckBytes(Temp)) {
|
if (!CheckBytes(Temp)) {
|
||||||
return;
|
return;
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
void ServerSend(std::string Data, bool Rel) {
|
void ServerSend(std::string Data, bool Rel) {
|
||||||
if (Terminate || Data.empty())
|
if (Terminate || Data.empty())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user