mirror of
https://github.com/overte-org/overte.git
synced 2025-08-04 21:45:15 +02:00
Add support for creating NLPacketList from PacketList
This commit is contained in:
parent
8032f05ed6
commit
46d5f73e4e
2 changed files with 28 additions and 7 deletions
|
@ -11,15 +11,27 @@
|
|||
|
||||
#include "NLPacketList.h"
|
||||
|
||||
#include "NLPacket.h"
|
||||
#include "udt/Packet.h"
|
||||
|
||||
NLPacketList::NLPacketList(PacketType packetType, QByteArray extendedHeader) :
|
||||
PacketList(packetType, extendedHeader)
|
||||
NLPacketList::NLPacketList(PacketType packetType, QByteArray extendedHeader, bool isReliable, bool isOrdered) :
|
||||
PacketList(packetType, extendedHeader, isReliable, isOrdered)
|
||||
{
|
||||
}
|
||||
|
||||
NLPacketList::NLPacketList(PacketList&& other) : PacketList(other.getType(), other.getExtendedHeader(), other.isReliable(), other.isOrdered()) {
|
||||
// Update _packets
|
||||
for (auto& packet : other._packets) {
|
||||
auto nlPacket = NLPacket::fromBase(std::move(packet));
|
||||
_packets.push_back(std::move(nlPacket));
|
||||
}
|
||||
|
||||
if (_packets.size() > 0) {
|
||||
auto nlPacket = static_cast<const NLPacket*>(_packets.front().get());
|
||||
_sourceID = nlPacket->getSourceID();
|
||||
_packetType = nlPacket->getType();
|
||||
}
|
||||
}
|
||||
|
||||
std::unique_ptr<udt::Packet> NLPacketList::createPacket() {
|
||||
return NLPacket::create(getType());
|
||||
return NLPacket::create(getType(), -1, isReliable(), isOrdered());
|
||||
}
|
||||
|
||||
|
|
|
@ -12,17 +12,26 @@
|
|||
#ifndef hifi_NLPacketList_h
|
||||
#define hifi_NLPacketList_h
|
||||
|
||||
#include <list>
|
||||
|
||||
#include "udt/PacketList.h"
|
||||
|
||||
#include "NLPacket.h"
|
||||
|
||||
class NLPacketList : public udt::PacketList {
|
||||
public:
|
||||
NLPacketList(PacketType packetType, QByteArray extendedHeader = QByteArray());
|
||||
NLPacketList(PacketType packetType, QByteArray extendedHeader = QByteArray(), bool isReliable = false, bool isOrdered = false);
|
||||
NLPacketList(PacketList&& packetList);
|
||||
|
||||
QUuid getSourceID() const { return _sourceID; }
|
||||
|
||||
private:
|
||||
NLPacketList(const NLPacketList& other) = delete;
|
||||
NLPacketList& operator=(const NLPacketList& other) = delete;
|
||||
|
||||
|
||||
virtual std::unique_ptr<udt::Packet> createPacket();
|
||||
|
||||
QUuid _sourceID;
|
||||
};
|
||||
|
||||
#endif // hifi_PacketList_h
|
||||
|
|
Loading…
Reference in a new issue