12#include <fairlogger/Logger.h>
14#define ASIO_CATCH(customMessage) \
15 catch (boost::system::system_error & err) \
17 auto msg = std::string{err.what()}; \
18 auto code = std::to_string(err.code().value()); \
19 throw std::runtime_error{"Exception in DataInspector (boost_code=" + code + ", boost_msg=" + msg + ") - " + customMessage}; \
22DIMessage::Header::Type DIMessage::Header::type()
const
24 return static_cast<DIMessage::Header::Type
>(boost::endian::little_to_native(typeLE));
27uint64_t DIMessage::Header::payloadSize()
const
29 return boost::endian::little_to_native(payloadSizeLE);
34 this->payload =
new char[
other.header.payloadSize()];
35 std::memcpy(this->payload,
other.payload,
other.header.payloadSize());
47 this->payload =
new char[
other.header.payloadSize()];
48 std::memcpy(this->payload,
other.payload,
other.header.payloadSize());
55 other.payload =
nullptr;
62 payload =
other.payload;
64 other.payload =
nullptr;
76 auto ip_address = boost::asio::ip::make_address(
address);
77 socket.connect(boost::asio::ip::tcp::endpoint(ip_address, port));
89 return socket.available() >=
sizeof(DIMessage::Header);
95 socket.send(std::array<boost::asio::const_buffer, 2>{
96 boost::asio::buffer(&
message.header,
sizeof(DIMessage::Header)),
97 boost::asio::buffer(
message.payload,
message.header.payloadSize())});
106 socket.receive(boost::asio::buffer(&
message.header,
sizeof(DIMessage::Header)));
108 if (
message.header.payloadSize() > 0) {
110 socket.receive(boost::asio::buffer(
message.payload,
message.header.payloadSize()));
#define ASIO_CATCH(customMessage)
bool isMessageAvailable()
void send(const DIMessage &message)
DISocket(const std::string &address, int port)
GLuint GLuint64EXT address
GLuint GLsizei const GLchar * message
DIMessage & operator=(const DIMessage &other) noexcept
VectorOfTObjectPtrs other