mirror of
https://github.com/BeamMP/BeamMP-Server.git
synced 2025-07-01 15:26:59 +00:00
Add server identification packet
This commit is contained in:
parent
4f052a3e0a
commit
6aeb2eb736
@ -29,6 +29,7 @@ public:
|
||||
//~THeartbeatThread();
|
||||
void operator()() override;
|
||||
|
||||
static inline std::string lastCall = "";
|
||||
private:
|
||||
std::string GenerateCall();
|
||||
std::string GetPlayers();
|
||||
|
@ -140,8 +140,7 @@ void THeartbeatThread::operator()() {
|
||||
std::string THeartbeatThread::GenerateCall() {
|
||||
std::stringstream Ret;
|
||||
|
||||
Ret << "uuid=" << Application::Settings.getAsString(Settings::Key::General_AuthKey)
|
||||
<< "&players=" << mServer.ClientCount()
|
||||
Ret << "players=" << mServer.ClientCount()
|
||||
<< "&maxplayers=" << Application::Settings.getAsInt(Settings::Key::General_MaxPlayers)
|
||||
<< "&port=" << Application::Settings.getAsInt(Settings::Key::General_Port)
|
||||
<< "&map=" << Application::Settings.getAsString(Settings::Key::General_Map)
|
||||
@ -156,6 +155,8 @@ std::string THeartbeatThread::GenerateCall() {
|
||||
<< "&modstotal=" << mResourceManager.ModsLoaded()
|
||||
<< "&playerslist=" << GetPlayers()
|
||||
<< "&desc=" << Application::Settings.getAsString(Settings::Key::General_Description);
|
||||
lastCall = Ret.str();
|
||||
Ret << "&uuid=" << Application::Settings.getAsString(Settings::Key::General_AuthKey);
|
||||
return Ret.str();
|
||||
}
|
||||
THeartbeatThread::THeartbeatThread(TResourceManager& ResourceManager, TServer& Server)
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "Client.h"
|
||||
#include "Common.h"
|
||||
#include "LuaAPI.h"
|
||||
#include "THeartbeatThread.h"
|
||||
#include "TLuaEngine.h"
|
||||
#include "TScopedTimer.h"
|
||||
#include "nlohmann/json.hpp"
|
||||
@ -246,6 +247,9 @@ void TNetwork::Identify(TConnection&& RawConnection) {
|
||||
boost::system::error_code ec;
|
||||
write(RawConnection.Socket, buffer("P"), ec);
|
||||
return;
|
||||
} else if (Code == 'I') {
|
||||
boost::system::error_code ec;
|
||||
write(RawConnection.Socket, buffer(THeartbeatThread::lastCall), ec);
|
||||
} else {
|
||||
beammp_errorf("Invalid code got in Identify: '{}'", Code);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user