F4MP/tiltedcode/Code/server/Services/AdminService.cpp
Jous99 37b16f1547 code upload
codigo original de f4mp y tilted para referencias
2026-01-06 18:45:00 +01:00

35 lines
962 B
C++

#include <GameServer.h>
#include <World.h>
#include <Services/AdminService.h>
#include <AdminMessages/AdminShutdownRequest.h>
#include <AdminMessages/ServerLogs.h>
AdminService::AdminService(World& aWorld, entt::dispatcher& aDispatcher)
: m_world(aWorld)
{
m_shutdownConnection = aDispatcher.sink<AdminPacketEvent<AdminShutdownRequest>>().connect<&AdminService::HandleShutdown>(this);
}
void AdminService::HandleShutdown(const AdminPacketEvent<AdminShutdownRequest>& acMessage) noexcept
{
spdlog::warn("Shutdown was requested by {:x}", acMessage.ConnectionId);
GameServer::Get()->Kill();
}
void AdminService::sink_it_(const spdlog::details::log_msg& msg)
{
spdlog::memory_buf_t formatted;
formatter_->format(msg, formatted);
ServerLogs logs;
logs.Logs = fmt::to_string(formatted);
GameServer::Get()->ForEachAdmin([&logs](ConnectionId_t aId) { GameServer::Get()->Send(aId, logs); });
}
void AdminService::flush_()
{
}