91 void setPort(
const unsigned int port);
97 void setIp(
const std::string &ip);
110 void setAddress(
const std::string &ip,
const unsigned int port);
134 std::string
bytesToHex(
const std::vector<uint8_t> &bytes);
182 bool _connectionActive =
false;
183 bool _continueListening =
true;
184 unsigned int _port = 9000;
185 std::vector<MessageNode> _bufferedMessages;
186 std::string _ip =
"127.0.0.1";
187 std::string _playerName =
"Player";
188 asio::io_context _ioContext;
189 asio::ip::udp::socket _socket{ _ioContext };
This is the file that links the EntityNode children.
Macro definitions for logging messages with varying levels of detail and formatting.
This is the file in charge of containing the Log class (the one in charge of outputing info only when...
This file defines the Packet class responsible for serializing and deserializing a custom binary UDP ...
A class that manages the network communication through UDP sockets.
const bool isConnected() const
Checks if the connection is active.
void setAddress(const std::string &ip, const unsigned int port)
Sets both the IP address and port for communication.
~NetworkManager()
Destroy the Network Manager object.
std::vector< GUI::Network::MessageNode > getBufferedMessages()
NetworkManager(const std::uint32_t entityId=0)
Constructs a NetworkManager instance with an optional entity ID.
void startGame()
starts a game by sending CONNECT TO server.
void sendMessage(const MessageNode &message)
Sends a message to the server.
void initialize()
Initializes the UDP socket and binds it to a local endpoint. This function opens the socket and binds...
std::string bytesToHex(const std::vector< uint8_t > &bytes)
Converts a byte array to a hexadecimal string representation.
void setPlayerName(const std::string &name)
Sets the player's name for identification.
void handleMessages()
Handles incoming messages on the UDP socket.
void startReceivingMessages()
void setIp(const std::string &ip)
Sets the IP address for communication.
void receiveMessage()
Receives messages continuously from the server.
std::string convertMessageToString(const MessageNode &message)
Translates a MessageNode into a string.
void setPort(const unsigned int port)
Sets the port for communication.
MessageNode translateMessage(const std::vector< uint8_t > &message)
Translates a message into a MessageNode.
float bytesToFloat(const uint8_t *bytes)
Converts a byte array to a floating-point value.
void stopReceivingMessages()