mirror of
https://github.com/overte-org/overte.git
synced 2025-04-07 22:33:04 +02:00
fixes for new read and NLPacketList
This commit is contained in:
parent
ad63be4efc
commit
0f534b9f7b
9 changed files with 31 additions and 22 deletions
|
@ -204,8 +204,7 @@ void AssignmentClientMonitor::checkSpares() {
|
|||
|
||||
void AssignmentClientMonitor::handleChildStatusPacket(QSharedPointer<NLPacket> packet) {
|
||||
// read out the sender ID
|
||||
QUuid senderID = QUuid::fromRfc4122(QByteArray::fromRawData(packet->getPayload(), NUM_BYTES_RFC4122_UUID));
|
||||
packet->seek(NUM_BYTES_RFC4122_UUID);
|
||||
QUuid senderID = QUuid::fromRfc4122(packet->read(NUM_BYTES_RFC4122_UUID));
|
||||
|
||||
auto nodeList = DependencyManager::get<NodeList>();
|
||||
|
||||
|
|
|
@ -15,9 +15,7 @@
|
|||
|
||||
int AvatarMixerClientData::parseData(NLPacket& packet) {
|
||||
// compute the offset to the data payload
|
||||
QByteArray byteArray = QByteArray::fromRawData(packet.getPayload() + packet.pos(),
|
||||
packet.bytesLeftToRead());
|
||||
return _avatar.parseDataFromBuffer(byteArray);
|
||||
return _avatar.parseDataFromBuffer(packet.read(packet.bytesLeftToRead()));
|
||||
}
|
||||
|
||||
bool AvatarMixerClientData::checkAndSetHasReceivedFirstPackets() {
|
||||
|
|
|
@ -971,13 +971,13 @@ void DomainServer::sendDomainListToNode(const SharedNodePointer& node, const Hif
|
|||
// this data is at the beginning of each of the domain list packets
|
||||
QByteArray extendedHeader(NUM_DOMAIN_LIST_EXTENDED_HEADER_BYTES, 0);
|
||||
QDataStream extendedHeaderStream(&extendedHeader, QIODevice::WriteOnly);
|
||||
|
||||
auto limitedNodeList = DependencyManager::get<LimitedNodeList>();
|
||||
|
||||
extendedHeaderStream << limitedNodeList->getSessionUUID();
|
||||
extendedHeaderStream << node->getUUID();
|
||||
extendedHeaderStream << (quint8) node->getCanAdjustLocks();
|
||||
extendedHeaderStream << (quint8) node->getCanRez();
|
||||
|
||||
auto limitedNodeList = DependencyManager::get<LimitedNodeList>();
|
||||
|
||||
NLPacketList domainListPackets(PacketType::DomainList, extendedHeader);
|
||||
|
||||
|
|
|
@ -112,9 +112,7 @@ int InboundAudioStream::parseData(NLPacket& packet) {
|
|||
int networkSamples;
|
||||
|
||||
// parse the info after the seq number and before the audio data (the stream properties)
|
||||
int propertyBytes = parseStreamProperties(packet.getType(),
|
||||
QByteArray::fromRawData(packet.getPayload() + packet.pos(), packet.bytesLeftToRead()),
|
||||
networkSamples);
|
||||
int propertyBytes = parseStreamProperties(packet.getType(), packet.read(packet.bytesLeftToRead()), networkSamples);
|
||||
packet.seek(packet.pos() + propertyBytes);
|
||||
|
||||
// handle this packet based on its arrival status.
|
||||
|
@ -133,10 +131,7 @@ int InboundAudioStream::parseData(NLPacket& packet) {
|
|||
if (packet.getType() == PacketType::SilentAudioFrame) {
|
||||
writeDroppableSilentSamples(networkSamples);
|
||||
} else {
|
||||
int audioBytes = parseAudioData(packet.getType(),
|
||||
QByteArray::fromRawData(packet.getPayload() + packet.pos(),
|
||||
packet.bytesLeftToRead()),
|
||||
networkSamples);
|
||||
int audioBytes = parseAudioData(packet.getType(), packet.read(packet.bytesLeftToRead()), networkSamples);
|
||||
packet.seek(packet.pos() + audioBytes);
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -55,8 +55,8 @@ void AvatarHashMap::processAvatarDataPacket(QSharedPointer<NLPacket> packet, Sha
|
|||
while (packet->bytesLeftToRead()) {
|
||||
QUuid sessionUUID = QUuid::fromRfc4122(packet->read(NUM_BYTES_RFC4122_UUID));
|
||||
|
||||
QByteArray byteArray = QByteArray::fromRawData(packet->getPayload() + packet->pos(),
|
||||
packet->bytesLeftToRead());
|
||||
QByteArray byteArray = packet->read(packet->bytesLeftToRead());
|
||||
|
||||
if (sessionUUID != _lastOwnerSessionUUID) {
|
||||
AvatarSharedPointer avatar = _avatarHash.value(sessionUUID);
|
||||
if (!avatar) {
|
||||
|
|
|
@ -13,7 +13,16 @@
|
|||
|
||||
#include "NLPacket.h"
|
||||
|
||||
NLPacketList::NLPacketList(PacketType::Value packetType) : PacketList(packetType) {
|
||||
NLPacketList::NLPacketList(PacketType::Value packetType) :
|
||||
PacketList(packetType)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
NLPacketList::NLPacketList(PacketType::Value packetType, const QByteArray& extendedHeader) :
|
||||
PacketList(packetType, extendedHeader)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
std::unique_ptr<Packet> NLPacketList::createPacket() {
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
class NLPacketList : public PacketList {
|
||||
public:
|
||||
NLPacketList(PacketType::Value packetType);
|
||||
NLPacketList(PacketType::Value packetType, const QByteArray& extendedHeader);
|
||||
|
||||
private:
|
||||
NLPacketList(const NLPacketList& other) = delete;
|
||||
|
|
|
@ -18,11 +18,18 @@
|
|||
PacketList::PacketList(PacketType::Value packetType) :
|
||||
_packetType(packetType)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
PacketList::PacketList(PacketType::Value packetType, const QByteArray& extendedHeader) :
|
||||
_packetType(packetType),
|
||||
_extendedHeader(extendedHeader)
|
||||
{
|
||||
QIODevice::open(WriteOnly);
|
||||
}
|
||||
|
||||
void PacketList::startSegment() {
|
||||
_segmentStartIndex = _currentPacket ? _currentPacket->pos() : 0;
|
||||
_segmentStartIndex = _currentPacket ? _currentPacket->pos() : _extendedHeader.size();
|
||||
}
|
||||
|
||||
void PacketList::endSegment() {
|
||||
|
@ -39,6 +46,7 @@ std::unique_ptr<Packet> PacketList::createPacketWithExtendedHeader() {
|
|||
auto packet = createPacket();
|
||||
|
||||
if (!_extendedHeader.isEmpty()) {
|
||||
qDebug() << "Writing a header of" << _extendedHeader.size();
|
||||
// add the extended header to the front of the packet
|
||||
if (packet->write(_extendedHeader) == -1) {
|
||||
qDebug() << "Could not write extendedHeader in PacketList::createPacketWithExtendedHeader"
|
||||
|
@ -89,7 +97,7 @@ qint64 PacketList::writeData(const char* data, qint64 maxSize) {
|
|||
newPacket->write(_currentPacket->getPayload() + _segmentStartIndex, segmentSize);
|
||||
|
||||
// the current segment now starts at the beginning of the new packet
|
||||
_segmentStartIndex = 0;
|
||||
_segmentStartIndex = _extendedHeader.size();
|
||||
|
||||
// shrink the current payload to the actual size of the packet
|
||||
_currentPacket->setPayloadSize(_segmentStartIndex);
|
||||
|
|
|
@ -22,6 +22,7 @@ class PacketList : public QIODevice {
|
|||
Q_OBJECT
|
||||
public:
|
||||
PacketList(PacketType::Value packetType);
|
||||
PacketList(PacketType::Value packetType, const QByteArray& extendedHeader);
|
||||
|
||||
virtual bool isSequential() const { return true; }
|
||||
|
||||
|
@ -33,8 +34,6 @@ public:
|
|||
|
||||
void closeCurrentPacket(bool shouldSendEmpty = false);
|
||||
|
||||
void setExtendedHeader(const QByteArray& extendedHeader) { _extendedHeader = extendedHeader; }
|
||||
|
||||
template<typename T> qint64 readPrimitive(T* data);
|
||||
template<typename T> qint64 writePrimitive(const T& data);
|
||||
protected:
|
||||
|
@ -83,4 +82,4 @@ template<typename T> std::unique_ptr<T> PacketList::takeFront() {
|
|||
return std::unique_ptr<T>(dynamic_cast<T*>(packet.release()));
|
||||
}
|
||||
|
||||
#endif // hifi_PacketList_h
|
||||
#endif // hifi_PacketList_h
|
||||
|
|
Loading…
Reference in a new issue