mirror of
https://github.com/BeamMP/BeamMP-Server.git
synced 2025-07-01 15:26:59 +00:00
Add size header to information packet (#409)
By creating this pull request, I understand that code that is AI generated or otherwise automatically generated may be rejected without further discussion. I declare that I fully understand all code I pushed into this PR, and wrote all this code myself and own the rights to this code.
This commit is contained in:
commit
c78775bfd8
@ -258,8 +258,16 @@ void TNetwork::Identify(TConnection&& RawConnection) {
|
|||||||
write(RawConnection.Socket, buffer("P"), ec);
|
write(RawConnection.Socket, buffer("P"), ec);
|
||||||
return;
|
return;
|
||||||
} else if (Code == 'I') {
|
} else if (Code == 'I') {
|
||||||
|
const std::string Data = Application::Settings.getAsBool(Settings::Key::General_InformationPacket) ? THeartbeatThread::lastCall : "";
|
||||||
|
|
||||||
|
const auto Size = static_cast<int32_t>(Data.size());
|
||||||
|
std::vector<uint8_t> ToSend;
|
||||||
|
ToSend.resize(Data.size() + sizeof(Size));
|
||||||
|
std::memcpy(ToSend.data(), &Size, sizeof(Size));
|
||||||
|
std::memcpy(ToSend.data() + sizeof(Size), Data.data(), Data.size());
|
||||||
|
|
||||||
boost::system::error_code ec;
|
boost::system::error_code ec;
|
||||||
write(RawConnection.Socket, buffer(Application::Settings.getAsBool(Settings::Key::General_InformationPacket) ? THeartbeatThread::lastCall : ""), ec);
|
write(RawConnection.Socket, buffer(ToSend), ec);
|
||||||
} else {
|
} else {
|
||||||
beammp_errorf("Invalid code got in Identify: '{}'", Code);
|
beammp_errorf("Invalid code got in Identify: '{}'", Code);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user