Files
DarkflameServer/dDashboardServer/handlers/DashboardPacketHandler.cpp
Aaron Kimbrell 910b92ffc7 WIP
2026-02-24 20:35:09 -06:00

69 lines
2.1 KiB
C++

#include "DashboardPacketHandler.h"
#include "BitStreamUtils.h"
#include "Logger.h"
#include "Game.h"
#include "handlers/MasterPacketHandler.h"
#include <functional>
#include <map>
namespace DashboardPacketHandler {
std::map<ServiceType, std::function<void()>> g_ServiceHandlers;
void DashboardNewIncomingConnection::Handle() {
LOG_DEBUG("DashboardPacketHandler: New incoming connection from %s", sysAddr.ToString(true));
}
void DashboardDisconnectionNotification::Handle() {
LOG_DEBUG("DashboardPacketHandler: Disconnection notification from %s", sysAddr.ToString(true));
}
void DashboardConnectionLost::Handle() {
LOG_DEBUG("DashboardPacketHandler: Connection lost with %s", sysAddr.ToString(true));
}
void DashboardConnectedPong::Handle() {
LOG_DEBUG("DashboardPacketHandler: Received pong from %s", sysAddr.ToString(true));
}
void DashboardUserPacketEnum::Handle() {
const auto it = g_ServiceHandlers.find(serviceType);
if (it != g_ServiceHandlers.end()) {
it->second();
} else {
LOG_DEBUG("DashboardPacketHandler: No handler registered for service type %u from %s", static_cast<uint16_t>(serviceType), sysAddr.ToString(true));
}
}
bool DashboardUserPacketEnum::Deserialize(RakNet::BitStream& bitStream) {
if (!PacketHandler::UserPacketEnum::Deserialize(bitStream)) {
return false;
}
VALIDATE_READ(bitStream.Read(serviceType));
return true;
}
void RegisterDashboardHandlers() {
// Override the default handlers with dashboard-specific implementations
PacketHandler::g_Handlers[ID_NEW_INCOMING_CONNECTION] = []() {
return std::make_unique<DashboardNewIncomingConnection>();
};
PacketHandler::g_Handlers[ID_DISCONNECTION_NOTIFICATION] = []() {
return std::make_unique<DashboardDisconnectionNotification>();
};
PacketHandler::g_Handlers[ID_CONNECTION_LOST] = []() {
return std::make_unique<DashboardConnectionLost>();
};
PacketHandler::g_Handlers[ID_CONNECTED_PONG] = []() {
return std::make_unique<DashboardConnectedPong>();
};
PacketHandler::g_Handlers[ID_USER_PACKET_ENUM] = []() {
return std::make_unique<DashboardUserPacketEnum>();
};
// Register service type handlers
}
}