14 throw std::invalid_argument(
"ENetPacket cannot be null");
19 : _packet(nullptr), _dataCacheValid(false) {
20 _packet = enet_packet_create(data.data(), data.size(), flags);
22 throw std::runtime_error(
"Failed to create ENet packet");
33 : _packet(other._packet),
34 _dataCache(std::move(other._dataCache)),
35 _dataCacheValid(other._dataCacheValid) {
36 other._packet =
nullptr;
37 other._dataCacheValid =
false;
43 enet_packet_destroy(_packet);
45 _packet = other._packet;
46 _dataCache = std::move(other._dataCache);
47 _dataCacheValid = other._dataCacheValid;
49 other._packet =
nullptr;
50 other._dataCacheValid =
false;
75 _packet = enet_packet_create(data.data(), data.size(), ENET_PACKET_FLAG_RELIABLE);
77 throw std::runtime_error(
"Failed to create ENet packet");
size_t getSize() const override
Get the size of the packet data in bytes.
const std::vector< uint8_t > & getData() const override
Get the packet data as a byte buffer.
std::vector< uint8_t > _dataCache
void setData(const std::vector< uint8_t > &data) override
Set new data for this packet.
ENetPacket * getNativePacket() const
~ENetPacketWrapper() override
ENetPacketWrapper(ENetPacket *packet)
ENetPacketWrapper & operator=(const ENetPacketWrapper &)=delete
uint32_t getFlags() const override
Get the flags associated with this packet.