mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-02-26 12:49:48 +00:00
WIP
This commit is contained in:
68
dDashboardServer/handlers/DashboardPacketHandler.cpp
Normal file
68
dDashboardServer/handlers/DashboardPacketHandler.cpp
Normal file
@@ -0,0 +1,68 @@
|
||||
#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
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user