17 #include <asio/ip/udp.hpp>
18 #include <asio/error_code.hpp>
19 #include <asio/io_context.hpp>
20 #include <asio/io_service.hpp>
21 #include <asio/placeholders.hpp>
23 #include "Registry.hpp"
26 #include "System/MoveSystem/MoveSystem.hpp"
27 #include "System/ReceiveSystem/ReceiveSystem.hpp"
28 #include "System/DirectionSystem/DirectionSystem.hpp"
29 #include "System/EndGameSystem/EndGameSystem.hpp"
30 #include "System/ShootSystem/ShootSystem.hpp"
32 #include "System/SpawnEnemySystem/SpawnEnemySystem.hpp"
33 #include "System/HitboxSystem/HitboxSystem.hpp"
34 #include "System/DisconnectionSystem/DisconnectionSystem.hpp"
35 #include "System/NewClientSystem/NewClientSystem.hpp"
36 #include "System/JoinLobbySystem/JoinLobbySystem.hpp"
37 #include "System/StartGameSystem/StartGameSystem.hpp"
40 #include "UdpCommunication.hpp"
41 #include "IUdpCommunication.hpp"
75 void ReceivePackets();
83 void HandleReceive(asio::error_code
const &e, std::size_t nbBytes);
88 void HandleSendPacket();
101 std::vector<std::string> loadMap(std::string
const &mapPath);
110 std::vector<std::string> getFilesListFromDirectory(std::string
const &directory, std::string
const &suffix);
118 std::vector<std::vector<std::string>> loadAllMaps(std::string
const &directoryPath);
120 asio::io_context _context;
122 std::queue<std::function<void(
void)>> _responseQueue;
124 std::shared_ptr<IUdpCommunication> _com;
126 std::vector<byte> _buffer_to_get;
132 std::unordered_map<asio::ip::address, std::unordered_map<unsigned short, int>> _endpoints;
148 bool _serverIsRunning =
true;
void setUpComponents()
Set the Up Components object.
Definition: Server.cpp:136
~Server()
Destroy the Server object.
Definition: Server.cpp:44
System in charge of dispatch in specific queues sended request from queue.
Definition: ReceiveSystem.hpp:30
The Direction System class, it handles all packets related to movement by the clients.
Definition: DirectionSystem.hpp:28
System in charge of handle start of game.
Definition: StartGameSystem.hpp:31
The Join Lobby System class, it handles all packets related to lobby join by the clients.
Definition: JoinLobbySystem.hpp:27
The Shoot System class, it handles all packets related to a mouse click by the user,...
Definition: ShootSystem.hpp:31
Class that handle ECS.
Definition: Registry.hpp:22
The Move System class, it handles all packets related to movement by the clients.
Definition: MoveSystem.hpp:30
The End Game System class, it handles the end of the game of lobbies.
Definition: EndGameSystem.hpp:27
The Disconnection System class, it handles disconnection of a client.
Definition: DisconnectionSystem.hpp:28
void setUpEcs()
Set the Up Ecs object.
Definition: Server.cpp:98
The SpawnEnemy System class, it handles all packets related to the spawn of an enemy in the game.
Definition: SpawnEnemySystem.hpp:37
The Hitbox System class, it handles everything related to collisions between entities.
Definition: HitboxSystem.hpp:31
Server(short const port)
Construct a new Server object.
Definition: Server.cpp:37
NewClientSystem class that handles the new client.
Definition: NewClientSystem.hpp:28
Server class to handle Server.
Definition: Server.hpp:46