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