1 #ifndef GRAIL_LIVE_DEBUGGER_SERVER_BINARY_H
2 #define GRAIL_LIVE_DEBUGGER_SERVER_BINARY_H
4 #include "LiveDebuggerServer.h"
6 #include "flatbuffers/flatbuffer_builder.h"
14 enum class DataDecorator : uint8_t
31 template <
typename SnapshotType>
32 void SendSnapshots(SnapshotType snapshot, DataDecorator dataDecorator)
34 if(tcpServer.IsAnyConnected())
37 auto serializedSnapshot = grail::data::Pack(builder, snapshot);
38 builder.Finish(serializedSnapshot);
39 auto decoratedBufferSize = builder.GetSize() + 1;
40 uint8_t* decoratedBuffer =
new uint8_t[decoratedBufferSize];
41 decoratedBuffer[0] =
static_cast<uint8_t
>(dataDecorator);
42 memcpy(decoratedBuffer + 1, builder.GetBufferPointer(), builder.GetSize() *
sizeof(uint8_t));
43 tcpServer.SendToAll(decoratedBuffer, decoratedBufferSize, DataType::BINARY);
44 delete[] decoratedBuffer;
48 flatbuffers::FlatBufferBuilder builder{};
53 #endif // GRAIL_LIVE_DEBUGGER_SERVER_BINARY_H