19#define ENSURE_THREAD_ALIVE(method) \
20 if (!isThreadAlive()) { \
21 PRETTY_ERROR << "No active thread for " << method << std::endl; \
22 throw CustomExceptions::NoActiveNetworkThread("<No running thread for " + std::string(method) + ">"); \
44 void setPort(
const unsigned int port);
45 void setIp(
const std::string &ip);
47 void setAddress(
const std::string &ip,
const unsigned int port);
53 const std::string
bytesToHex(
const std::vector<uint8_t> &bytes);
63 std::thread _childThread;
64 unsigned int _port = 9000;
65 mutable std::mutex _mutex;
66 std::string _ip =
"127.0.0.1";
67 std::string _playerName =
"Player";
68 std::atomic<bool> _childAlive =
false;
69 std::shared_ptr<NetworkManager> _childNode;
This file defines the NetworkManager class, which handles UDP socket communication for sending and re...
void sendMessage(const MessageNode &message)
void setPort(const unsigned int port)
const bool isConnected() const
const std::vector< GUI::Network::MessageNode > getReceivedMessages()
const float bytesToFloat(const uint8_t *bytes)
ThreadCapsule(const std::uint32_t nodeId=0)
void setPlayerName(const std::string &name)
void setAddress(const std::string &ip, const unsigned int port)
const std::string bytesToHex(const std::vector< uint8_t > &bytes)
const bool isThreadAlive() const
const GUI::Network::MessageNode translateMessage(const std::vector< uint8_t > &message)
void setIp(const std::string &ip)