10#include "Systems/NetworkSyncSystem.hpp"
24 , _registry(registry) {};
47 tempPacket >> payload;
48 log::info(
"InputTick: session={} mask={}", sessionId,
59 auto &inputs = inputsRes->get();
60 if (inputs.has(entity)) {
61 inputs[entity].
lastMask = inputs[entity].mask;
78 log::info(
"Destroyed entity {} for disconnected session {}",
79 entity.
index(), sessionId);
89 tempPacket >> payload;
90 log::info(
"Player new connection [not logged]: session={}",
100 if (entity.index() == entityId) {
101 log::info(
"sendPacketToEntity: sending packet to session {} "
103 sessionId, entityId);
108 log::warning(
"sendPacketToEntity: no session bound to entity {}",
120 const std::vector<uint32_t> &sessions,
const net::Packet &packet,
123 for (uint32_t sessionId : sessions) {
Represents an entity in the ECS (Entity-Component-System) architecture.
constexpr std::uint32_t index(void) const
auto add(Entity entity, Args &&...args) -> std::expected< std::reference_wrapper< T >, rtp::Error >
auto get(this const Self &self) -> std::expected< std::reference_wrapper< ConstLike< Self, SparseArray< T > > >, rtp::Error >
Network packet with header and serializable body.
void handleDisconnect(uint32_t sessionId)
Handle disconnection of a client.
void sendPacketToSessions(const std::vector< uint32_t > &sessions, const net::Packet &packet, net::NetworkMode mode)
Send a packet to multiple sessions.
ServerNetwork & _network
Reference to the server network manager.
uint32_t handlePlayerConnection(uint32_t sessionId, const net::Packet &packet)
Handle new player connection.
void handleInput(uint32_t sessionId, const net::Packet &packet)
Handle input received from a client.
ecs::Registry & _registry
Reference to the entity registry.
void sendPacketToSession(uint32_t sessionId, const net::Packet &packet, net::NetworkMode mode)
Send a packet to a specific session.
NetworkSyncSystem(ServerNetwork &network, ecs::Registry ®istry)
Constructor for NetworkSyncSystem.
std::unordered_map< uint32_t, ecs::Entity > _sessionToEntity
Map of session IDs to entities (with generation)
void update(float dt) override
Update system logic for one frame.
void sendPacketToEntity(uint32_t entityId, const net::Packet &packet, net::NetworkMode mode)
Send a packet to the entity associated with the given ID.
void unbindSession(uint32_t sessionId)
void bindSessionToEntity(uint32_t sessionId, ecs::Entity entity)
Bind a network session to an entity.
Implementation ASIO du serveur réseau (TCP + UDP)
void sendPacket(uint32_t sessionId, const net::Packet &packet, net::NetworkMode mode)
Send a packet to a specific session.
void warning(LogFmt< std::type_identity_t< Args >... > fmt, Args &&...args) noexcept
Log a warning message.
void info(LogFmt< std::type_identity_t< Args >... > fmt, Args &&...args) noexcept
Log an informational message.
NetworkMode
Enum representing network transmission modes.
File : GameManager.hpp License: MIT Author : Elias Josué HAJJAR LLAUQUEN elias-josue....
Player connection data sended Client OpCode.
uint32_t sessionId
Session identifier.