8#ifndef R_TYPE_NETWORKMANAGER_HPP
9#define R_TYPE_NETWORKMANAGER_HPP
11#include "uranus/engine/Engine.hpp"
14#include <saturnity/Saturnity.hpp>
16namespace rtype::client::network {
19 static std::shared_ptr<NetworkManager> &getInstance();
23 void connectTcpClient(
const std::string &host, std::uint16_t port);
24 void connectUdpClient(
const std::string &host, std::uint16_t port);
32 void send(sa::AbstractPacket &packet);
33 void send(
const std::shared_ptr<sa::AbstractPacket> &packet);
34 void send(
const std::unique_ptr<sa::AbstractPacket> &packet);
36 const std::shared_ptr<sa::TCPClient> &getTcpClient()
const
41 const std::shared_ptr<sa::UDPClient> &getUdpClient()
const
46 std::string imGuiHost =
"127.0.0.1";
47 std::string imGuiTcpPort =
"2409";
48 std::string imGuiUdpPort =
"2410";
49 std::string imGuiUsername;
51 std::uint16_t tcpPort = 2409;
52 std::uint16_t udpPort = 2410;
54 std::uint32_t uid = 0;
60 imGuiUsername =
"Player-" + std::to_string(_random.
generate(0, 99999999));
65 this->imGuiReady =
false;
68 static std::shared_ptr<NetworkManager> networkManager;
69 std::shared_ptr<spdlog::logger> _logger;
71 std::shared_ptr<sa::PacketRegistry> _udpPacketRegistry;
72 std::shared_ptr<sa::PacketRegistry> _tcpPacketRegistry;
74 std::shared_ptr<sa::TCPClient> _tcpClient;
75 std::shared_ptr<sa::UDPClient> _udpClient;
77 void registerUdpCallback();
78 void registerTcpCallback();
80 void registerUdpPacketHandlers();
81 void registerTcpPacketHandlers();
All packets used in the project.
Definition: Random.hpp:13
short generate(short min, short max)
Generate a random short using the std::default_random_engine & uniform_int_distribution.
Definition: Random.hpp:26
Definition: NetworkManager.hpp:17