mirror of
https://github.com/overte-org/overte.git
synced 2025-07-19 05:47:59 +02:00
51 lines
1.7 KiB
C++
51 lines
1.7 KiB
C++
//
|
|
// NLPacketList.cpp
|
|
// libraries/networking/src
|
|
//
|
|
// Created by Stephen Birarda on 07/06/15.
|
|
// Copyright 2015 High Fidelity, Inc.
|
|
//
|
|
// Distributed under the Apache License, Version 2.0.
|
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
|
//
|
|
|
|
#include "NLPacketList.h"
|
|
|
|
#include "udt/Packet.h"
|
|
|
|
|
|
std::unique_ptr<NLPacketList> NLPacketList::create(PacketType packetType, QByteArray extendedHeader,
|
|
bool isReliable, bool isOrdered) {
|
|
auto nlPacketList = std::unique_ptr<NLPacketList>(new NLPacketList(packetType, extendedHeader,
|
|
isReliable, isOrdered));
|
|
nlPacketList->open(WriteOnly);
|
|
return nlPacketList;
|
|
}
|
|
|
|
std::unique_ptr<NLPacketList> NLPacketList::fromPacketList(std::unique_ptr<PacketList> packetList) {
|
|
auto nlPacketList = std::unique_ptr<NLPacketList>(new NLPacketList(std::move(*packetList.release()))); nlPacketList->open(ReadOnly);
|
|
return nlPacketList;
|
|
}
|
|
|
|
|
|
NLPacketList::NLPacketList(PacketType packetType, QByteArray extendedHeader, bool isReliable, bool isOrdered) :
|
|
PacketList(packetType, extendedHeader, isReliable, isOrdered)
|
|
{
|
|
}
|
|
|
|
NLPacketList::NLPacketList(PacketList&& other) : PacketList(std::move(other)) {
|
|
// Update _packets
|
|
for (auto& packet : _packets) {
|
|
packet = NLPacket::fromBase(std::move(packet));
|
|
}
|
|
|
|
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(), -1, isReliable(), isOrdered());
|
|
}
|