mirror of
https://github.com/overte-org/overte.git
synced 2025-04-22 16:13:28 +02:00
Merge branch 'protocol' of https://github.com/Atlante45/hifi into atp
This commit is contained in:
commit
6b05b7ef31
6 changed files with 55 additions and 17 deletions
|
@ -135,9 +135,10 @@ class Application;
|
|||
|
||||
typedef bool (Application::* AcceptURLMethod)(const QString &);
|
||||
|
||||
class Application : public QApplication,
|
||||
class Application :
|
||||
public QApplication,
|
||||
public AbstractViewStateInterface,
|
||||
AbstractScriptingServicesInterface,
|
||||
public AbstractScriptingServicesInterface,
|
||||
public PacketListener {
|
||||
Q_OBJECT
|
||||
|
||||
|
|
|
@ -216,10 +216,10 @@ bool LimitedNodeList::packetSourceAndHashMatch(const NLPacket& packet, SharedNod
|
|||
return false;
|
||||
}
|
||||
|
||||
// NLPacket helper for filling the header
|
||||
void writePacketHeader(const NLPacket& packet, const QUuid& sessionUUID = QUuid(), const QUuid& connectionSecret = QUuid()) {
|
||||
qint64 LimitedNodeList::writePacket(const NLPacket& packet, const HifiSockAddr& destinationSockAddr,
|
||||
const QUuid& connectionSecret) {
|
||||
if (!NON_SOURCED_PACKETS.contains(packet.getType())) {
|
||||
const_cast<NLPacket&>(packet).writeSourceID(sessionUUID);
|
||||
const_cast<NLPacket&>(packet).writeSourceID(getSessionUUID());
|
||||
}
|
||||
|
||||
if (!connectionSecret.isNull()
|
||||
|
@ -227,12 +227,7 @@ void writePacketHeader(const NLPacket& packet, const QUuid& sessionUUID = QUuid(
|
|||
&& !NON_VERIFIED_PACKETS.contains(packet.getType())) {
|
||||
const_cast<NLPacket&>(packet).writeVerificationHash(packet.payloadHashWithConnectionUUID(connectionSecret));
|
||||
}
|
||||
}
|
||||
|
||||
qint64 LimitedNodeList::writeDatagram(const NLPacket& packet, const HifiSockAddr& destinationSockAddr,
|
||||
const QUuid& connectionSecret) {
|
||||
writePacketHeader(packet, getSessionUUID(), connectionSecret);
|
||||
return writeDatagram({ packet.getData(), (int) packet.getDataSize() }, destinationSockAddr);
|
||||
return writeDatagram({ packet.getData(), (int)packet.getDataSize() }, destinationSockAddr);
|
||||
}
|
||||
|
||||
qint64 LimitedNodeList::writeDatagram(const QByteArray& datagram, const HifiSockAddr& destinationSockAddr) {
|
||||
|
@ -264,7 +259,7 @@ qint64 LimitedNodeList::sendUnreliablePacket(const NLPacket& packet, const Node&
|
|||
|
||||
qint64 LimitedNodeList::sendUnreliablePacket(const NLPacket& packet, const HifiSockAddr& sockAddr,
|
||||
const QUuid& connectionSecret) {
|
||||
return writeDatagram(packet, sockAddr, connectionSecret);
|
||||
return writePacket(packet, sockAddr, connectionSecret);
|
||||
}
|
||||
|
||||
qint64 LimitedNodeList::sendPacket(std::unique_ptr<NLPacket> packet, const Node& destinationNode) {
|
||||
|
@ -280,7 +275,7 @@ qint64 LimitedNodeList::sendPacket(std::unique_ptr<NLPacket> packet, const Node&
|
|||
|
||||
qint64 LimitedNodeList::sendPacket(std::unique_ptr<NLPacket> packet, const HifiSockAddr& sockAddr,
|
||||
const QUuid& connectionSecret) {
|
||||
return writeDatagram(*packet, sockAddr, connectionSecret);
|
||||
return writePacket(*packet, sockAddr, connectionSecret);
|
||||
}
|
||||
|
||||
qint64 LimitedNodeList::sendPacketList(NLPacketList& packetList, const Node& destinationNode) {
|
||||
|
@ -501,7 +496,7 @@ unsigned int LimitedNodeList::broadcastToNodes(std::unique_ptr<NLPacket> packet,
|
|||
|
||||
eachNode([&](const SharedNodePointer& node){
|
||||
if (destinationNodeTypes.contains(node->getType())) {
|
||||
writeDatagram(*packet, *node->getActiveSocket());
|
||||
writePacket(*packet, *node->getActiveSocket(), node->getConnectionSecret());
|
||||
++n;
|
||||
}
|
||||
});
|
||||
|
|
|
@ -248,8 +248,8 @@ protected:
|
|||
LimitedNodeList(LimitedNodeList const&); // Don't implement, needed to avoid copies of singleton
|
||||
void operator=(LimitedNodeList const&); // Don't implement, needed to avoid copies of singleton
|
||||
|
||||
qint64 writeDatagram(const NLPacket& packet, const HifiSockAddr& destinationSockAddr,
|
||||
const QUuid& connectionSecret = QUuid());
|
||||
qint64 writePacket(const NLPacket& packet, const HifiSockAddr& destinationSockAddr,
|
||||
const QUuid& connectionSecret = QUuid());
|
||||
qint64 writeDatagram(const QByteArray& datagram, const HifiSockAddr& destinationSockAddr);
|
||||
|
||||
PacketSequenceNumber getNextSequenceNumberForPacket(const QUuid& nodeUUID, PacketType::Value packetType);
|
||||
|
|
|
@ -14,5 +14,8 @@
|
|||
#include "NodeList.h"
|
||||
|
||||
PacketListener::~PacketListener() {
|
||||
DependencyManager::get<LimitedNodeList>()->getPacketReceiver().unregisterListener(this);
|
||||
auto limitedNodelist = DependencyManager::get<LimitedNodeList>();
|
||||
if (limitedNodelist) {
|
||||
limitedNodelist->getPacketReceiver().unregisterListener(this);
|
||||
}
|
||||
}
|
||||
|
|
14
tests/networking/src/PacketTests.cpp
Normal file
14
tests/networking/src/PacketTests.cpp
Normal file
|
@ -0,0 +1,14 @@
|
|||
//
|
||||
// PacketTests.cpp
|
||||
// tests/networking/src
|
||||
//
|
||||
// Created by Stephen Birarda on 07/14/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 "PacketTests.h"
|
||||
|
||||
QTEST_MAIN(PacketTests)
|
25
tests/networking/src/PacketTests.h
Normal file
25
tests/networking/src/PacketTests.h
Normal file
|
@ -0,0 +1,25 @@
|
|||
//
|
||||
// PacketTests.h
|
||||
// tests/networking/src
|
||||
//
|
||||
// Created by Stephen Birarda on 07/14/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
|
||||
//
|
||||
|
||||
#ifndef hifi_PacketTests_h
|
||||
#define hifi_PacketTests_h
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QtTest/QtTest>
|
||||
|
||||
class PacketTests : public QObject {
|
||||
Q_OBJECT
|
||||
private slots:
|
||||
void readTest();
|
||||
};
|
||||
|
||||
#endif // hifi_PacketTests_h
|
Loading…
Reference in a new issue