Air-Trap 1.0.0
A multiplayer R-Type clone game engine built with C++23 and ECS architecture
Loading...
Searching...
No Matches
NetworkSyncSystem.hpp
Go to the documentation of this file.
1
8#ifndef RTYPE_NETWORK_NetworkSyncSystem_HPP_
9 #define RTYPE_NETWORK_NetworkSyncSystem_HPP_
10
11 #include "RType/ECS/ISystem.hpp"
12 #include "RType/ECS/Registry.hpp"
14
21
22 #include <vector>
23 #include <unordered_map>
24
29namespace rtp::server {
30
36 public:
43
49 void update(float dt) override;
50
56 void bindSessionToEntity(uint32_t sessionId, ecs::Entity entity);
57 void unbindSession(uint32_t sessionId);
58
64 void handleInput(uint32_t sessionId, const net::Packet& packet);
65
70 void handleDisconnect(uint32_t sessionId);
71
77 uint32_t handlePlayerConnection(uint32_t sessionId, const net::Packet& packet);
78
85 void sendPacketToEntity(uint32_t entityId, const net::Packet& packet, net::NetworkMode mode);
86
93 void sendPacketToSession(uint32_t sessionId, const net::Packet& packet, net::NetworkMode mode);
94
101 void sendPacketToSessions(const std::vector<uint32_t>& sessions, const net::Packet& packet, net::NetworkMode mode);
102
103 private:
106 std::unordered_map<uint32_t,
108 };
109}
110
111#endif /* !RTYPE_NETWORK_NetworkSyncSystem_HPP_ */
Interface for ECS systems.
Network packet implementation for R-Type protocol.
Represents an entity in the ECS (Entity-Component-System) architecture.
Definition Entity.hpp:63
Abstract base class for all ECS systems.
Definition ISystem.hpp:57
Network packet with header and serializable body.
Definition Packet.hpp:471
System to handle network-related operations on the server side.
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.
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)
NetworkMode
Enum representing network transmission modes.
Definition INetwork.hpp:25
File : GameManager.hpp License: MIT Author : Elias Josué HAJJAR LLAUQUEN elias-josue....