• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Razakhel / RaZ / 19909051101

03 Dec 2025 09:04PM UTC coverage: 74.363% (-0.06%) from 74.418%
19909051101

push

github

Razakhel
[Extern/ImGui] Updated ImGui to 1.92.5 & ImPlot to commit 285df9 (0.17+)

- Removed the fonts/ & freetype/ folders which are technically unused for now

- Inserted ImGui's new cursor pos callback

0 of 3 new or added lines in 1 file covered. (0.0%)

5 existing lines in 4 files now uncovered.

8525 of 11464 relevant lines covered (74.36%)

1724.47 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

92.31
/src/RaZ/Network/UdpServer.cpp
1
#include "RaZ/Network/UdpServer.hpp"
2
#include "RaZ/Utils/Logger.hpp"
3

4
#include "asio/ip/udp.hpp"
5

6
namespace Raz {
7

8
struct UdpServer::Impl {
9
  Impl() : socket(context) {}
2✔
10

11
  asio::io_context context;
12
  asio::ip::udp::socket socket;
13
  asio::ip::udp::endpoint senderEndpoint;
14
  std::array<char, 1024> data {};
15
};
16

17
UdpServer::UdpServer() : m_impl{ std::make_unique<Impl>() } {}
2✔
18

19
void UdpServer::start(unsigned short port) {
2✔
20
  Logger::debug("[UdpServer] Starting on port {}...", port);
2✔
21

22
  setup(port);
2✔
23
  receive();
2✔
24

25
  m_impl->context.run();
2✔
26
}
2✔
27

28
void UdpServer::stop() {
3✔
29
  Logger::debug("[UdpServer] Stopping...");
3✔
30
  // shutdown() shouldn't be called on UDP sockets
31
  m_impl->socket.close();
3✔
32
  m_impl->context.stop();
3✔
33
  Logger::debug("[UdpServer] Stopped");
3✔
34
}
3✔
35

36
UdpServer::~UdpServer() = default;
2✔
37

38
void UdpServer::setup(unsigned short port) {
2✔
39
  if (m_impl->context.stopped())
2✔
40
    m_impl->context.restart();
1✔
41

42
  const asio::ip::udp::endpoint endpoint(asio::ip::udp::v4(), port);
2✔
43
  m_impl->socket.open(endpoint.protocol());
2✔
44
  m_impl->socket.set_option(asio::socket_base::reuse_address(true));
2✔
45
  m_impl->socket.bind(endpoint);
2✔
46
}
2✔
47

48
void UdpServer::receive() {
4✔
49
  m_impl->socket.async_receive_from(asio::buffer(m_impl->data), m_impl->senderEndpoint, [this] (const asio::error_code& error, std::size_t bytesReceived) {
4✔
50
    if (error == asio::error::interrupted || error == asio::error::operation_aborted)
2✔
UNCOV
51
      return; // Server closed
×
52

53
    if (error) {
2✔
54
      Logger::error("[UdpServer] Error while receiving data: {}", error.message());
×
55
    } else {
56
      Logger::debug("[UdpServer] Received data from {}: {}", m_impl->senderEndpoint.address().to_string(), std::string_view(m_impl->data.data(), bytesReceived));
4✔
57
      echo(bytesReceived); // Replying with the same received data
2✔
58
    }
59

60
    receive();
2✔
61
  });
62
}
4✔
63

64
void UdpServer::echo(std::size_t length) {
2✔
65
  m_impl->socket.async_send_to(asio::buffer(m_impl->data, length), m_impl->senderEndpoint, [] (const asio::error_code& error, std::size_t) {
2✔
66
    if (error)
2✔
67
      Logger::error("[UdpServer] Error while echoing: {}", error.message());
×
68
  });
2✔
69
}
2✔
70

71
} // namespace Raz
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc