mirror of
https://github.com/overte-org/overte.git
synced 2025-04-30 01:22:34 +02:00
Merge branch 'atp' of https://github.com/birarda/hifi into protocol
This commit is contained in:
commit
632bc3aa40
32 changed files with 150 additions and 122 deletions
|
@ -18,7 +18,7 @@ AvatarAudioStream::AvatarAudioStream(bool isStereo, const InboundAudioStream::Se
|
|||
{
|
||||
}
|
||||
|
||||
int AvatarAudioStream::parseStreamProperties(PacketType type, const QByteArray& packetAfterSeqNum, int& numAudioSamples) {
|
||||
int AvatarAudioStream::parseStreamProperties (PacketType::Value type, const QByteArray& packetAfterSeqNum, int& numAudioSamples) {
|
||||
int readBytes = 0;
|
||||
|
||||
if (type == PacketTypeSilentAudioFrame) {
|
||||
|
|
|
@ -25,7 +25,7 @@ private:
|
|||
AvatarAudioStream(const AvatarAudioStream&);
|
||||
AvatarAudioStream& operator= (const AvatarAudioStream&);
|
||||
|
||||
int parseStreamProperties(PacketType type, const QByteArray& packetAfterSeqNum, int& numAudioSamples);
|
||||
int parseStreamProperties (PacketType::Value type, const QByteArray& packetAfterSeqNum, int& numAudioSamples);
|
||||
};
|
||||
|
||||
#endif // hifi_AvatarAudioStream_h
|
||||
|
|
|
@ -1322,14 +1322,14 @@ void DomainServer::pingPunchForConnectingPeer(const SharedNetworkPeer& peer) {
|
|||
|
||||
_icePeers.remove(peer->getUUID());
|
||||
} else {
|
||||
auto nodeList = DependencyManager::get<LimitedNodeList>();
|
||||
auto limitedNodeList = DependencyManager::get<LimitedNodeList>();
|
||||
|
||||
// send the ping packet to the local and public sockets for this node
|
||||
QByteArray localPingPacket = nodeList->constructPingPacket(PingType::Local, false);
|
||||
nodeList->writeUnverifiedDatagram(localPingPacket, peer->getLocalSocket());
|
||||
auto localPingPacket = nodeList->constructICEPingPacket(PingType::Local, limitedNodeList->getSessionUUID());
|
||||
limitedNodeList->sendPacket(localPingPacket, peer->getLocalSocket());
|
||||
|
||||
QByteArray publicPingPacket = nodeList->constructPingPacket(PingType::Public, false);
|
||||
nodeList->writeUnverifiedDatagram(publicPingPacket, peer->getPublicSocket());
|
||||
auto publicPingPacket = nodeList->constructICEPingPacket(PingType::Public, limitedNodeList->getSessionUUID());
|
||||
limitedNodeList->sendPacket(publicPingPacket, peer->getPublicSocket());
|
||||
|
||||
peer->incrementConnectionAttempts();
|
||||
}
|
||||
|
|
|
@ -1097,13 +1097,6 @@ void Application::updateProjectionMatrix(Camera& camera, bool updateViewFrustum)
|
|||
glMatrixMode(GL_MODELVIEW);
|
||||
}
|
||||
|
||||
void Application::controlledBroadcastToNodes(const QByteArray& packet, const NodeSet& destinationNodeTypes) {
|
||||
foreach(NodeType_t type, destinationNodeTypes) {
|
||||
// Perform the broadcast for one type
|
||||
DependencyManager::get<NodeList>()->broadcastToNodes(packet, NodeSet() << type);
|
||||
}
|
||||
}
|
||||
|
||||
bool Application::importSVOFromURL(const QString& urlString) {
|
||||
QUrl url(urlString);
|
||||
emit svoImportRequested(url.url());
|
||||
|
@ -1763,10 +1756,21 @@ bool Application::acceptSnapshot(const QString& urlString) {
|
|||
}
|
||||
|
||||
void Application::sendPingPackets() {
|
||||
QByteArray pingPacket = DependencyManager::get<NodeList>()->constructPingPacket();
|
||||
controlledBroadcastToNodes(pingPacket, NodeSet()
|
||||
<< NodeType::EntityServer
|
||||
<< NodeType::AudioMixer << NodeType::AvatarMixer);
|
||||
|
||||
auto nodeList = DependencyManager::get<NodeList>();
|
||||
|
||||
nodeList->eachMatchingNode([](const SharedNodePointer& node)->bool {
|
||||
switch (node->getType()) {
|
||||
case NodeType::AvatarMixer:
|
||||
case NodeType::AudioMixer:
|
||||
case NodeType::EntityServer:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}, [nodeList](const SharedNodePointer& node) {
|
||||
nodeList->sendPacket(std::move(nodeList->constructPingPacket()), node);
|
||||
});
|
||||
}
|
||||
|
||||
// Every second, check the frame rates and other stuff
|
||||
|
|
|
@ -271,8 +271,6 @@ public:
|
|||
|
||||
void resetProfile(const QString& username);
|
||||
|
||||
void controlledBroadcastToNodes(const QByteArray& packet, const NodeSet& destinationNodeTypes);
|
||||
|
||||
virtual void setupWorldLight();
|
||||
virtual bool shouldRenderMesh(float largestDimension, float distanceToCamera);
|
||||
|
||||
|
|
|
@ -168,7 +168,7 @@ int InboundAudioStream::parseData(const QByteArray& packet) {
|
|||
return readBytes;
|
||||
}
|
||||
|
||||
int InboundAudioStream::parseStreamProperties(PacketType type, const QByteArray& packetAfterSeqNum, int& numAudioSamples) {
|
||||
int InboundAudioStream::parseStreamProperties (PacketType::Value type, const QByteArray& packetAfterSeqNum, int& numAudioSamples) {
|
||||
if (type == PacketTypeSilentAudioFrame) {
|
||||
quint16 numSilentSamples = 0;
|
||||
memcpy(&numSilentSamples, packetAfterSeqNum.constData(), sizeof(quint16));
|
||||
|
@ -181,7 +181,7 @@ int InboundAudioStream::parseStreamProperties(PacketType type, const QByteArray&
|
|||
}
|
||||
}
|
||||
|
||||
int InboundAudioStream::parseAudioData(PacketType type, const QByteArray& packetAfterStreamProperties, int numAudioSamples) {
|
||||
int InboundAudioStream::parseAudioData (PacketType::Value type, const QByteArray& packetAfterStreamProperties, int numAudioSamples) {
|
||||
return _ringBuffer.writeData(packetAfterStreamProperties.data(), numAudioSamples * sizeof(int16_t));
|
||||
}
|
||||
|
||||
|
|
|
@ -194,11 +194,11 @@ protected:
|
|||
/// parses the info between the seq num and the audio data in the network packet and calculates
|
||||
/// how many audio samples this packet contains (used when filling in samples for dropped packets).
|
||||
/// default implementation assumes no stream properties and raw audio samples after stream propertiess
|
||||
virtual int parseStreamProperties(PacketType type, const QByteArray& packetAfterSeqNum, int& networkSamples);
|
||||
virtual int parseStreamProperties (PacketType::Value type, const QByteArray& packetAfterSeqNum, int& networkSamples);
|
||||
|
||||
/// parses the audio data in the network packet.
|
||||
/// default implementation assumes packet contains raw audio samples after stream properties
|
||||
virtual int parseAudioData(PacketType type, const QByteArray& packetAfterStreamProperties, int networkSamples);
|
||||
virtual int parseAudioData (PacketType::Value type, const QByteArray& packetAfterStreamProperties, int networkSamples);
|
||||
|
||||
/// writes silent samples to the buffer that may be dropped to reduce latency caused by the buffer
|
||||
virtual int writeDroppableSilentSamples(int silentSamples);
|
||||
|
|
|
@ -30,7 +30,7 @@ InjectedAudioStream::InjectedAudioStream(const QUuid& streamIdentifier, const bo
|
|||
|
||||
const uchar MAX_INJECTOR_VOLUME = 255;
|
||||
|
||||
int InjectedAudioStream::parseStreamProperties(PacketType type,
|
||||
int InjectedAudioStream::parseStreamProperties (PacketType::Value type,
|
||||
const QByteArray& packetAfterSeqNum,
|
||||
int& numAudioSamples) {
|
||||
// setup a data stream to read from this packet
|
||||
|
|
|
@ -31,7 +31,7 @@ private:
|
|||
InjectedAudioStream& operator= (const InjectedAudioStream&);
|
||||
|
||||
AudioStreamStats getAudioStreamStats() const;
|
||||
int parseStreamProperties(PacketType type, const QByteArray& packetAfterSeqNum, int& numAudioSamples);
|
||||
int parseStreamProperties (PacketType::Value type, const QByteArray& packetAfterSeqNum, int& numAudioSamples);
|
||||
|
||||
const QUuid _streamIdentifier;
|
||||
float _radius;
|
||||
|
|
|
@ -42,7 +42,7 @@ int MixedProcessedAudioStream::writeLastFrameRepeatedWithFade(int samples) {
|
|||
return deviceSamplesWritten;
|
||||
}
|
||||
|
||||
int MixedProcessedAudioStream::parseAudioData(PacketType type, const QByteArray& packetAfterStreamProperties, int networkSamples) {
|
||||
int MixedProcessedAudioStream::parseAudioData (PacketType::Value type, const QByteArray& packetAfterStreamProperties, int networkSamples) {
|
||||
|
||||
emit addedStereoSamples(packetAfterStreamProperties);
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ public:
|
|||
protected:
|
||||
int writeDroppableSilentSamples(int silentSamples);
|
||||
int writeLastFrameRepeatedWithFade(int samples);
|
||||
int parseAudioData(PacketType type, const QByteArray& packetAfterStreamProperties, int networkSamples);
|
||||
int parseAudioData (PacketType::Value type, const QByteArray& packetAfterStreamProperties, int networkSamples);
|
||||
|
||||
private:
|
||||
int networkToDeviceSamples(int networkSamples);
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
#include "EntityItem.h"
|
||||
|
||||
|
||||
void EntityEditPacketSender::adjustEditPacketForClockSkew(PacketType type,
|
||||
void EntityEditPacketSender::adjustEditPacketForClockSkew (PacketType::Value type,
|
||||
unsigned char* editBuffer, size_t length, int clockSkew) {
|
||||
|
||||
if (type == PacketTypeEntityAdd || type == PacketTypeEntityEdit) {
|
||||
|
@ -26,7 +26,7 @@ void EntityEditPacketSender::adjustEditPacketForClockSkew(PacketType type,
|
|||
}
|
||||
}
|
||||
|
||||
void EntityEditPacketSender::queueEditEntityMessage(PacketType type, EntityItemID modelID,
|
||||
void EntityEditPacketSender::queueEditEntityMessage (PacketType::Value type, EntityItemID modelID,
|
||||
const EntityItemProperties& properties) {
|
||||
if (!_shouldSend) {
|
||||
return; // bail early
|
||||
|
|
|
@ -24,12 +24,12 @@ public:
|
|||
/// which voxel-server node or nodes the packet should be sent to. Can be called even before voxel servers are known, in
|
||||
/// which case up to MaxPendingMessages will be buffered and processed when voxel servers are known.
|
||||
/// NOTE: EntityItemProperties assumes that all distances are in meter units
|
||||
void queueEditEntityMessage(PacketType type, EntityItemID modelID, const EntityItemProperties& properties);
|
||||
void queueEditEntityMessage (PacketType::Value type, EntityItemID modelID, const EntityItemProperties& properties);
|
||||
|
||||
void queueEraseEntityMessage(const EntityItemID& entityItemID);
|
||||
|
||||
// My server type is the model server
|
||||
virtual char getMyNodeType() const { return NodeType::EntityServer; }
|
||||
virtual void adjustEditPacketForClockSkew(PacketType type, unsigned char* editBuffer, size_t length, int clockSkew);
|
||||
virtual void adjustEditPacketForClockSkew (PacketType::Value type, unsigned char* editBuffer, size_t length, int clockSkew);
|
||||
};
|
||||
#endif // hifi_EntityEditPacketSender_h
|
||||
|
|
|
@ -614,7 +614,7 @@ void EntityItemPropertiesFromScriptValueHonorReadOnly(const QScriptValue &object
|
|||
//
|
||||
// TODO: Implement support for script and visible properties.
|
||||
//
|
||||
bool EntityItemProperties::encodeEntityEditPacket(PacketType command, EntityItemID id, const EntityItemProperties& properties,
|
||||
bool EntityItemProperties::encodeEntityEditPacket (PacketType::Value command, EntityItemID id, const EntityItemProperties& properties,
|
||||
unsigned char* bufferOut, int sizeIn, int& sizeOut) {
|
||||
OctreePacketData ourDataPacket(false, sizeIn); // create a packetData object to add out packet details too.
|
||||
OctreePacketData* packetData = &ourDataPacket; // we want a pointer to this so we can use our APPEND_ENTITY_PROPERTY macro
|
||||
|
|
|
@ -174,7 +174,7 @@ public:
|
|||
void setGlowLevel(float value) { _glowLevel = value; _glowLevelChanged = true; }
|
||||
void setLocalRenderAlpha(float value) { _localRenderAlpha = value; _localRenderAlphaChanged = true; }
|
||||
|
||||
static bool encodeEntityEditPacket(PacketType command, EntityItemID id, const EntityItemProperties& properties,
|
||||
static bool encodeEntityEditPacket (PacketType::Value command, EntityItemID id, const EntityItemProperties& properties,
|
||||
unsigned char* bufferOut, int sizeIn, int& sizeOut);
|
||||
|
||||
static bool encodeEraseEntityMessage(const EntityItemID& entityItemID,
|
||||
|
|
|
@ -32,7 +32,7 @@ EntityScriptingInterface::EntityScriptingInterface() :
|
|||
connect(nodeList.data(), &NodeList::canRezChanged, this, &EntityScriptingInterface::canRezChanged);
|
||||
}
|
||||
|
||||
void EntityScriptingInterface::queueEntityMessage(PacketType packetType,
|
||||
void EntityScriptingInterface::queueEntityMessage (PacketType::Value packetType,
|
||||
EntityItemID entityID, const EntityItemProperties& properties) {
|
||||
getEntityPacketSender()->queueEditEntityMessage(packetType, entityID, properties);
|
||||
}
|
||||
|
|
|
@ -164,7 +164,7 @@ private:
|
|||
bool actionWorker(const QUuid& entityID, std::function<bool(EntitySimulation*, EntityItemPointer)> actor);
|
||||
bool setVoxels(QUuid entityID, std::function<void(PolyVoxEntityItem&)> actor);
|
||||
bool setPoints(QUuid entityID, std::function<bool(LineEntityItem&)> actor);
|
||||
void queueEntityMessage(PacketType packetType, EntityItemID entityID, const EntityItemProperties& properties);
|
||||
void queueEntityMessage (PacketType::Value packetType, EntityItemID entityID, const EntityItemProperties& properties);
|
||||
|
||||
/// actually does the work of finding the ray intersection, can be called in locking mode or tryLock mode
|
||||
RayToEntityIntersectionResult findRayIntersectionWorker(const PickRay& ray, Octree::lockType lockType,
|
||||
|
|
|
@ -63,7 +63,7 @@ void EntityTree::eraseAllOctreeElements(bool createNewRoot) {
|
|||
Octree::eraseAllOctreeElements(createNewRoot);
|
||||
}
|
||||
|
||||
bool EntityTree::handlesEditPacketType(PacketType packetType) const {
|
||||
bool EntityTree::handlesEditPacketType (PacketType::Value packetType) const {
|
||||
// we handle these types of "edit" packets
|
||||
switch (packetType) {
|
||||
case PacketTypeEntityAdd:
|
||||
|
@ -572,7 +572,7 @@ EntityItemPointer EntityTree::findEntityByEntityItemID(const EntityItemID& entit
|
|||
return foundEntity;
|
||||
}
|
||||
|
||||
int EntityTree::processEditPacketData(PacketType packetType, const unsigned char* packetData, int packetLength,
|
||||
int EntityTree::processEditPacketData (PacketType::Value packetType, const unsigned char* packetData, int packetLength,
|
||||
const unsigned char* editData, int maxLength, const SharedNodePointer& senderNode) {
|
||||
|
||||
if (!getIsServer()) {
|
||||
|
|
|
@ -65,8 +65,8 @@ public:
|
|||
virtual PacketType::Value expectedDataPacketType() const { return PacketTypeEntityData; }
|
||||
virtual bool canProcessVersion(PacketVersion thisVersion) const
|
||||
{ return thisVersion >= VERSION_ENTITIES_USE_METERS_AND_RADIANS; }
|
||||
virtual bool handlesEditPacketType(PacketType packetType) const;
|
||||
virtual int processEditPacketData(PacketType packetType, const unsigned char* packetData, int packetLength,
|
||||
virtual bool handlesEditPacketType (PacketType::Value packetType) const;
|
||||
virtual int processEditPacketData (PacketType::Value packetType, const unsigned char* packetData, int packetLength,
|
||||
const unsigned char* editData, int maxLength, const SharedNodePointer& senderNode);
|
||||
|
||||
virtual bool rootElementHasData() const { return true; }
|
||||
|
|
|
@ -68,9 +68,9 @@ Assignment::Assignment(const QByteArray& packet) :
|
|||
{
|
||||
PacketType::Value packetType = packetTypeForPacket(packet);
|
||||
|
||||
if (packetType == PacketTypeRequestAssignment) {
|
||||
if (packetType == PacketType::RequestAssignment) {
|
||||
_command = Assignment::RequestCommand;
|
||||
} else if (packetType == PacketTypeCreateAssignment) {
|
||||
} else if (packetType == PacketType::CreateAssignment) {
|
||||
_command = Assignment::CreateCommand;
|
||||
}
|
||||
|
||||
|
|
|
@ -168,10 +168,10 @@ bool LimitedNodeList::packetVersionAndHashMatch(const QByteArray& packet) {
|
|||
int numPacketTypeBytes = numBytesArithmeticCodingFromBuffer(packet.data());
|
||||
|
||||
if (packet[numPacketTypeBytes] != versionForPacketType(checkType)
|
||||
&& checkType != PacketTypeStunResponse) {
|
||||
&& checkType != PacketType::StunResponse) {
|
||||
PacketType::Value mismatchType = packetTypeForPacket(packet);
|
||||
|
||||
static QMultiMap<QUuid, PacketType> versionDebugSuppressMap;
|
||||
static QMultiMap<QUuid, PacketType::Value> versionDebugSuppressMap;
|
||||
|
||||
QUuid senderUUID = uuidFromPacketHeader(packet);
|
||||
if (!versionDebugSuppressMap.contains(senderUUID, checkType)) {
|
||||
|
@ -195,7 +195,7 @@ bool LimitedNodeList::packetVersionAndHashMatch(const QByteArray& packet) {
|
|||
if (hashFromPacketHeader(packet) == hashForPacketAndConnectionUUID(packet, sendingNode->getConnectionSecret())) {
|
||||
return true;
|
||||
} else {
|
||||
static QMultiMap<QUuid, PacketType> hashDebugSuppressMap;
|
||||
static QMultiMap<QUuid, PacketType::Value> hashDebugSuppressMap;
|
||||
|
||||
QUuid senderUUID = uuidFromPacketHeader(packet);
|
||||
if (!hashDebugSuppressMap.contains(senderUUID, checkType)) {
|
||||
|
@ -521,14 +521,11 @@ unsigned LimitedNodeList::broadcastToNodes(const QByteArray& packet, const NodeS
|
|||
return n;
|
||||
}
|
||||
|
||||
QByteArray LimitedNodeList::constructPingPacket(PingType_t pingType, bool isVerified, const QUuid& packetHeaderID) {
|
||||
NodeListPacket&& LimitedNodeList::constructPingPacket(PingType_t pingType) {
|
||||
int packetSize = sizeof(PingType_t) + sizeof(quint64);
|
||||
NodeListPacket pingPacket = NodeListPacket::create(PacketType::Ping, packetSize);
|
||||
|
||||
QUuid packetUUID = packetHeaderID.isNull() ? _sessionUUID : packetHeaderID;
|
||||
|
||||
QByteArray pingPacket = byteArrayWithUUIDPopulatedHeader(isVerified ? PacketTypePing : PacketTypeUnverifiedPing,
|
||||
packetUUID);
|
||||
|
||||
QDataStream packetStream(&pingPacket, QIODevice::Append);
|
||||
QDataStream packetStream(&pingPacket.payload(), QIODevice::Append);
|
||||
|
||||
packetStream << pingType;
|
||||
packetStream << usecTimestampNow();
|
||||
|
@ -536,7 +533,7 @@ QByteArray LimitedNodeList::constructPingPacket(PingType_t pingType, bool isVeri
|
|||
return pingPacket;
|
||||
}
|
||||
|
||||
QByteArray LimitedNodeList::constructPingReplyPacket(const QByteArray& pingPacket, const QUuid& packetHeaderID) {
|
||||
NodeListPacket&& LimitedNodeList::constructPingReplyPacket(const QByteArray& pingPacket) {
|
||||
QDataStream pingPacketStream(pingPacket);
|
||||
pingPacketStream.skipRawData(numBytesForPacketHeader(pingPacket));
|
||||
|
||||
|
@ -546,19 +543,43 @@ QByteArray LimitedNodeList::constructPingReplyPacket(const QByteArray& pingPacke
|
|||
quint64 timeFromOriginalPing;
|
||||
pingPacketStream >> timeFromOriginalPing;
|
||||
|
||||
PacketType::Value replyType = (packetTypeForPacket(pingPacket) == PacketTypePing)
|
||||
? PacketTypePingReply : PacketTypeUnverifiedPingReply;
|
||||
int packetSize = sizeof(PingType_t) + sizeof(quint64) + sizeof(quint64);
|
||||
|
||||
QUuid packetUUID = packetHeaderID.isNull() ? _sessionUUID : packetHeaderID;
|
||||
NodeListPacket replyPacket = NodeListPacket::create(PacketType::Ping, packetSize);
|
||||
|
||||
QByteArray replyPacket = byteArrayWithUUIDPopulatedHeader(replyType, packetUUID);
|
||||
QDataStream packetStream(&replyPacket, QIODevice::Append);
|
||||
|
||||
packetStream << typeFromOriginalPing << timeFromOriginalPing << usecTimestampNow();
|
||||
|
||||
return replyPacket;
|
||||
}
|
||||
|
||||
NodeListPacket&& constructICEPingPacket(PingType_t pingType, const QUuid& iceID) {
|
||||
int packetSize = NUM_BYTES_RFC4122_UUID + sizeof(PingType_t);
|
||||
|
||||
NodeListPacket icePingPacket = NodeListPacket::create(PacketType::ICEPing, packetSize);
|
||||
|
||||
icePingPacket.payload().replace(0, NUM_BYTES_RFC4122_UUID, iceID.toRfc4122().data());
|
||||
memcpy(icePingPacket.payload() + NUM_BYTES_RFC4122_UUID, &pingType, sizeof(PingType_t));
|
||||
|
||||
return icePingPacket;
|
||||
}
|
||||
|
||||
NodeListPacket&& constructICEPingReplyPacket(const QByteArray& pingPacket, const QUuid& iceID) {
|
||||
// pull out the ping type so we can reply back with that
|
||||
PingType_t pingType;
|
||||
|
||||
memcpy(&pingType, pingPacket.data() + NUM_BYTES_RFC4122_UUID, sizeof(PingType_t));
|
||||
|
||||
int packetSize = NUM_BYTES_RFC4122_UUID + sizeof(PingType_t);
|
||||
NodeListPacket icePingReplyPacket = NodeListPacket::create(PacketType::ICEPingReply, packetSize);
|
||||
|
||||
// pack the ICE ID and then the ping type
|
||||
memcpy(icePingReplyPacket.payload(), iceID.toRfc4122().data(), NUM_BYTES_RFC4122_UUID);
|
||||
memcpy(icePingReplyPacket.payload() + NUM_BYTES_RFC4122_UUID, &pingType, sizeof(PingType_t));
|
||||
|
||||
return icePingReplyPacket;
|
||||
}
|
||||
|
||||
SharedNodePointer LimitedNodeList::soloNodeOfType(char nodeType) {
|
||||
return nodeMatchingPredicate([&](const SharedNodePointer& node){
|
||||
return node->getType() == nodeType;
|
||||
|
@ -835,7 +856,7 @@ void LimitedNodeList::sendPeerQueryToIceServer(const HifiSockAddr& iceServerSock
|
|||
sendPacketToIceServer(PacketTypeIceServerQuery, iceServerSockAddr, clientID, peerID);
|
||||
}
|
||||
|
||||
void LimitedNodeList::sendPacketToIceServer(PacketType packetType, const HifiSockAddr& iceServerSockAddr,
|
||||
void LimitedNodeList::sendPacketToIceServer(PacketType::Value packetType, const HifiSockAddr& iceServerSockAddr,
|
||||
const QUuid& headerID, const QUuid& peerID) {
|
||||
|
||||
QByteArray iceRequestByteArray = byteArrayWithUUIDPopulatedHeader(packetType, headerID);
|
||||
|
|
|
@ -118,28 +118,28 @@ public:
|
|||
|
||||
bool packetVersionAndHashMatch(const QByteArray& packet);
|
||||
|
||||
// QByteArray byteArrayWithPopulatedHeader(PacketType packetType)
|
||||
// QByteArray byteArrayWithPopulatedHeader (PacketType::Value packetType)
|
||||
// { return byteArrayWithUUIDPopulatedHeader(packetType, _sessionUUID); }
|
||||
// int populatePacketHeader(QByteArray& packet, PacketType::Value packetType)
|
||||
// { return populatePacketHeaderWithUUID(packet, packetType, _sessionUUID); }
|
||||
// int populatePacketHeader(char* packet, PacketType::Value packetType)
|
||||
// { return populatePacketHeaderWithUUID(packet, packetType, _sessionUUID); }
|
||||
|
||||
qint64 readDatagram(QByteArray& incomingPacket, QHostAddress* address, quint16 * port);
|
||||
|
||||
qint64 writeDatagram(const QByteArray& datagram, const SharedNodePointer& destinationNode,
|
||||
const HifiSockAddr& overridenSockAddr = HifiSockAddr());
|
||||
|
||||
qint64 writeUnverifiedDatagram(const QByteArray& datagram, const SharedNodePointer& destinationNode,
|
||||
const HifiSockAddr& overridenSockAddr = HifiSockAddr());
|
||||
|
||||
qint64 writeUnverifiedDatagram(const QByteArray& datagram, const HifiSockAddr& destinationSockAddr);
|
||||
|
||||
qint64 writeDatagram(const char* data, qint64 size, const SharedNodePointer& destinationNode,
|
||||
const HifiSockAddr& overridenSockAddr = HifiSockAddr());
|
||||
|
||||
qint64 writeUnverifiedDatagram(const char* data, qint64 size, const SharedNodePointer& destinationNode,
|
||||
const HifiSockAddr& overridenSockAddr = HifiSockAddr());
|
||||
// qint64 readDatagram(QByteArray& incomingPacket, QHostAddress* address, quint16 * port);
|
||||
//
|
||||
// qint64 writeDatagram(const QByteArray& datagram, const SharedNodePointer& destinationNode,
|
||||
// const HifiSockAddr& overridenSockAddr = HifiSockAddr());
|
||||
//
|
||||
// qint64 writeUnverifiedDatagram(const QByteArray& datagram, const SharedNodePointer& destinationNode,
|
||||
// const HifiSockAddr& overridenSockAddr = HifiSockAddr());
|
||||
//
|
||||
// qint64 writeUnverifiedDatagram(const QByteArray& datagram, const HifiSockAddr& destinationSockAddr);
|
||||
//
|
||||
// qint64 writeDatagram(const char* data, qint64 size, const SharedNodePointer& destinationNode,
|
||||
// const HifiSockAddr& overridenSockAddr = HifiSockAddr());
|
||||
//
|
||||
// qint64 writeUnverifiedDatagram(const char* data, qint64 size, const SharedNodePointer& destinationNode,
|
||||
// const HifiSockAddr& overridenSockAddr = HifiSockAddr());
|
||||
|
||||
void (*linkedDataCreateCallback)(Node *);
|
||||
|
||||
|
@ -170,9 +170,11 @@ public:
|
|||
void getPacketStats(float &packetsPerSecond, float &bytesPerSecond);
|
||||
void resetPacketStats();
|
||||
|
||||
QByteArray constructPingPacket(PingType_t pingType = PingType::Agnostic, bool isVerified = true,
|
||||
const QUuid& packetHeaderID = QUuid());
|
||||
QByteArray constructPingReplyPacket(const QByteArray& pingPacket, const QUuid& packetHeaderID = QUuid());
|
||||
NodeListPacket&& constructPingPacket(PingType_t pingType = PingType::Agnostic);
|
||||
NodeListPacket&& constructPingReplyPacket(const QByteArray& pingPacket);
|
||||
|
||||
NodeListPacket&& constructICEPingPacket(PingType_t pingType, const QUuid& iceID);
|
||||
NodeListPacket&& constructICEPingReplyPacket(const QByteArray& pingPacket, const QUuid& iceID);
|
||||
|
||||
virtual bool processSTUNResponse(const QByteArray& packet);
|
||||
|
||||
|
@ -274,7 +276,7 @@ protected:
|
|||
|
||||
void stopInitialSTUNUpdate(bool success);
|
||||
|
||||
void sendPacketToIceServer(PacketType packetType, const HifiSockAddr& iceServerSockAddr, const QUuid& headerID,
|
||||
void sendPacketToIceServer (PacketType::Value packetType, const HifiSockAddr& iceServerSockAddr, const QUuid& headerID,
|
||||
const QUuid& peerRequestID = QUuid());
|
||||
|
||||
QUuid _sessionUUID;
|
||||
|
|
|
@ -67,7 +67,7 @@ void Node::updateClockSkewUsec(int clockSkewSample) {
|
|||
_clockSkewUsec = (int)_clockSkewMovingPercentile.getValueAtPercentile();
|
||||
}
|
||||
|
||||
PacketSequenceNumber Node::getLastSequenceNumberForPacketType(PacketType packetType) const {
|
||||
PacketSequenceNumber Node::getLastSequenceNumberForPacketType (PacketType::Value packetType) const {
|
||||
auto typeMatch = _lastSequenceNumbers.find(packetType);
|
||||
if (typeMatch != _lastSequenceNumbers.end()) {
|
||||
return typeMatch->second;
|
||||
|
|
|
@ -67,7 +67,7 @@ public:
|
|||
|
||||
void setLastSequenceNumberForPacketType(PacketSequenceNumber sequenceNumber, PacketType::Value packetType)
|
||||
{ _lastSequenceNumbers[packetType] = sequenceNumber; }
|
||||
PacketSequenceNumber getLastSequenceNumberForPacketType(PacketType packetType) const;
|
||||
PacketSequenceNumber getLastSequenceNumberForPacketType(PacketType::Value packetType) const;
|
||||
|
||||
friend QDataStream& operator<<(QDataStream& out, const Node& node);
|
||||
friend QDataStream& operator>>(QDataStream& in, Node& node);
|
||||
|
|
|
@ -175,36 +175,36 @@ void NodeList::timePingReply(const QByteArray& packet, const SharedNodePointer&
|
|||
void NodeList::processNodeData(const HifiSockAddr& senderSockAddr, const QByteArray& packet) {
|
||||
PacketType::Value packetType = packetTypeForPacket(packet);
|
||||
switch (packetType) {
|
||||
case PacketTypeDomainList:
|
||||
case PacketTypeDomainServerAddedNode: {
|
||||
case PacketType::DomainList:
|
||||
case PacketType::DomainServerAddedNode: {
|
||||
if (!_domainHandler.getSockAddr().isNull()) {
|
||||
// only process a packet from domain-server if we're talking to a domain
|
||||
// TODO: how do we make sure this is actually the domain we want the list from (DTLS probably)
|
||||
if (packetType == PacketTypeDomainList) {
|
||||
if (packetType == PacketType::DomainList) {
|
||||
processDomainServerList(packet);
|
||||
} else if (packetType == PacketTypeDomainServerAddedNode) {
|
||||
} else if (packetType == PacketType::DomainServerAddedNode) {
|
||||
processDomainServerAddedNode(packet);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case PacketTypeDomainServerRequireDTLS: {
|
||||
case PacketType::DomainServerRequireDTLS: {
|
||||
_domainHandler.parseDTLSRequirementPacket(packet);
|
||||
break;
|
||||
}
|
||||
case PacketTypeIceServerPeerInformation: {
|
||||
case PacketType::IceServerPeerInformation: {
|
||||
if (!_domainHandler.getICEPeer().hasSockets()) {
|
||||
_domainHandler.processICEResponsePacket(packet);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case PacketTypePing: {
|
||||
case PacketType::Ping: {
|
||||
// send back a reply
|
||||
SharedNodePointer matchingNode = sendingNodeForPacket(packet);
|
||||
if (matchingNode) {
|
||||
matchingNode->setLastHeardMicrostamp(usecTimestampNow());
|
||||
QByteArray replyPacket = constructPingReplyPacket(packet);
|
||||
writeDatagram(replyPacket, matchingNode, senderSockAddr);
|
||||
auto replyPacket = constructPingReplyPacket(packet);
|
||||
sendPacket(replyPacket, matchingNode, senderSockAddr);
|
||||
|
||||
// If we don't have a symmetric socket for this node and this socket doesn't match
|
||||
// what we have for public and local then set it as the symmetric.
|
||||
|
@ -218,7 +218,7 @@ void NodeList::processNodeData(const HifiSockAddr& senderSockAddr, const QByteAr
|
|||
|
||||
break;
|
||||
}
|
||||
case PacketTypePingReply: {
|
||||
case PacketType::PingReply: {
|
||||
SharedNodePointer sendingNode = sendingNodeForPacket(packet);
|
||||
|
||||
if (sendingNode) {
|
||||
|
@ -233,13 +233,13 @@ void NodeList::processNodeData(const HifiSockAddr& senderSockAddr, const QByteAr
|
|||
|
||||
break;
|
||||
}
|
||||
case PacketTypeUnverifiedPing: {
|
||||
case PacketType::ICEPing: {
|
||||
// send back a reply
|
||||
QByteArray replyPacket = constructPingReplyPacket(packet, _domainHandler.getICEClientID());
|
||||
writeUnverifiedDatagram(replyPacket, senderSockAddr);
|
||||
auto replyPacket = constructICEPingReplyPacket(packet, _domainHandler.getICEClientID());
|
||||
sendPacket(replyPacket, senderSockAddr);
|
||||
break;
|
||||
}
|
||||
case PacketTypeUnverifiedPingReply: {
|
||||
case PacketType::ICEPingReply: {
|
||||
qCDebug(networking) << "Received reply from domain-server on" << senderSockAddr;
|
||||
|
||||
if (_domainHandler.getIP().isNull()) {
|
||||
|
@ -256,13 +256,13 @@ void NodeList::processNodeData(const HifiSockAddr& senderSockAddr, const QByteAr
|
|||
|
||||
}
|
||||
}
|
||||
case PacketTypeStunResponse: {
|
||||
case PacketType::StunResponse: {
|
||||
// a STUN packet begins with 00, we've checked the second zero with packetVersionMatch
|
||||
// pass it along so it can be processed into our public address and port
|
||||
processSTUNResponse(packet);
|
||||
break;
|
||||
}
|
||||
case PacketTypeDomainServerPathResponse: {
|
||||
case PacketType::DomainServerPathResponse: {
|
||||
handleDSPathQueryResponse(packet);
|
||||
break;
|
||||
}
|
||||
|
@ -518,11 +518,11 @@ void NodeList::pingPunchForDomainServer() {
|
|||
flagTimeForConnectionStep(LimitedNodeList::ConnectionStep::SendPingsToDS);
|
||||
|
||||
// send the ping packet to the local and public sockets for this node
|
||||
QByteArray localPingPacket = constructPingPacket(PingType::Local, false, _domainHandler.getICEClientID());
|
||||
writeUnverifiedDatagram(localPingPacket, _domainHandler.getICEPeer().getLocalSocket());
|
||||
auto localPingPacket = constructICEPingPacket(PingType::Local);
|
||||
sendPacket(localPingPacket, _domainHandler.getICEPeer().getLocalSocket());
|
||||
|
||||
QByteArray publicPingPacket = constructPingPacket(PingType::Public, false, _domainHandler.getICEClientID());
|
||||
writeUnverifiedDatagram(publicPingPacket, _domainHandler.getICEPeer().getPublicSocket());
|
||||
auto publicPingPacket = constructICEPingPacket(PingType::Public);
|
||||
sendPacket(publicPingPacket, _domainHandler.getICEPeer().getPublicSocket());
|
||||
|
||||
_domainHandler.getICEPeer().incrementConnectionAttempts();
|
||||
}
|
||||
|
@ -625,15 +625,15 @@ void NodeList::pingPunchForInactiveNode(const SharedNodePointer& node) {
|
|||
}
|
||||
|
||||
// send the ping packet to the local and public sockets for this node
|
||||
QByteArray localPingPacket = constructPingPacket(PingType::Local);
|
||||
writeDatagram(localPingPacket, node, node->getLocalSocket());
|
||||
auto localPingPacket = constructPingPacket(PingType::Local);
|
||||
sendPacket(localPingPacket, node, node->getLocalSocket());
|
||||
|
||||
QByteArray publicPingPacket = constructPingPacket(PingType::Public);
|
||||
writeDatagram(publicPingPacket, node, node->getPublicSocket());
|
||||
auto publicPingPacket = constructPingPacket(PingType::Public);
|
||||
sendPacket(publicPingPacket, node, node->getPublicSocket());
|
||||
|
||||
if (!node->getSymmetricSocket().isNull()) {
|
||||
QByteArray symmetricPingPacket = constructPingPacket(PingType::Symmetric);
|
||||
writeDatagram(symmetricPingPacket, node, node->getSymmetricSocket());
|
||||
auto symmetricPingPacket = constructPingPacket(PingType::Symmetric);
|
||||
sendPacket(symmetricPingPacket, node, node->getSymmetricSocket());
|
||||
}
|
||||
|
||||
node->incrementConnectionAttempts();
|
||||
|
|
|
@ -31,6 +31,8 @@ const QSet<PacketType::Value> NON_VERIFIED_PACKETS = QSet<PacketType::Value>()
|
|||
|
||||
const QSet<PacketType::Value> SEQUENCE_NUMBERED_PACKETS = QSet<PacketType::Value>() << AvatarData;
|
||||
|
||||
const QSet<PacketType::Value> NON_SOURCED_PACKETS = QSet<PacketType::Value>() << ICEPing << ICEPingReply;
|
||||
|
||||
int arithmeticCodingValueFromBuffer(const char* checkValue) {
|
||||
if (((uchar) *checkValue) < 255) {
|
||||
return *checkValue;
|
||||
|
|
|
@ -78,9 +78,9 @@ namespace PacketType {
|
|||
AudioEnvironment,
|
||||
EntityEditNack,
|
||||
SignedTransactionPayment,
|
||||
IceServerHeartbeat, // 50
|
||||
UnverifiedPing,
|
||||
UnverifiedPingReply
|
||||
ICEServerHeartbeat, // 50
|
||||
ICEPing,
|
||||
ICEPingReply
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -93,6 +93,7 @@ typedef std::map<PacketType::Value, PacketSequenceNumber> PacketTypeSequenceMap;
|
|||
|
||||
extern const QSet<PacketType::Value> NON_VERIFIED_PACKETS;
|
||||
extern const QSet<PacketType::Value> SEQUENCE_NUMBERED_PACKETS;
|
||||
extern const QSet<PacketType::Value> NON_SOURCED_PACKETS;
|
||||
|
||||
const int NUM_BYTES_MD5_HASH = 16;
|
||||
const int NUM_STATIC_HEADER_BYTES = sizeof(PacketVersion) + NUM_BYTES_RFC4122_UUID;
|
||||
|
|
|
@ -20,7 +20,7 @@ EditPacketBuffer::EditPacketBuffer() :
|
|||
|
||||
}
|
||||
|
||||
EditPacketBuffer::EditPacketBuffer(PacketType type, unsigned char* buffer, size_t length, qint64 satoshiCost, QUuid nodeUUID) :
|
||||
EditPacketBuffer::EditPacketBuffer (PacketType::Value type, unsigned char* buffer, size_t length, qint64 satoshiCost, QUuid nodeUUID) :
|
||||
_nodeUUID(nodeUUID),
|
||||
_currentType(type),
|
||||
_currentSize(length),
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
class EditPacketBuffer {
|
||||
public:
|
||||
EditPacketBuffer();
|
||||
EditPacketBuffer(PacketType type, unsigned char* codeColorBuffer, size_t length,
|
||||
EditPacketBuffer (PacketType::Value type, unsigned char* codeColorBuffer, size_t length,
|
||||
qint64 satoshiCost = 0, const QUuid nodeUUID = QUuid());
|
||||
|
||||
QUuid _nodeUUID;
|
||||
|
|
|
@ -230,8 +230,8 @@ public:
|
|||
virtual bool canProcessVersion(PacketVersion thisVersion) const {
|
||||
return thisVersion == versionForPacketType(expectedDataPacketType()); }
|
||||
virtual PacketVersion expectedVersion() const { return versionForPacketType(expectedDataPacketType()); }
|
||||
virtual bool handlesEditPacketType(PacketType packetType) const { return false; }
|
||||
virtual int processEditPacketData(PacketType packetType, const unsigned char* packetData, int packetLength,
|
||||
virtual bool handlesEditPacketType (PacketType::Value packetType) const { return false; }
|
||||
virtual int processEditPacketData (PacketType::Value packetType, const unsigned char* packetData, int packetLength,
|
||||
const unsigned char* editData, int maxLength, const SharedNodePointer& sourceNode) { return 0; }
|
||||
|
||||
virtual bool recurseChildrenWithData() const { return true; }
|
||||
|
|
|
@ -159,7 +159,7 @@ void OctreeEditPacketSender::processPreServerExistsPackets() {
|
|||
}
|
||||
}
|
||||
|
||||
void OctreeEditPacketSender::queuePendingPacketToNodes(PacketType type, unsigned char* buffer,
|
||||
void OctreeEditPacketSender::queuePendingPacketToNodes (PacketType::Value type, unsigned char* buffer,
|
||||
size_t length, qint64 satoshiCost) {
|
||||
// If we're asked to save messages while waiting for voxel servers to arrive, then do so...
|
||||
|
||||
|
@ -213,7 +213,7 @@ void OctreeEditPacketSender::queuePacketToNodes(unsigned char* buffer, size_t le
|
|||
|
||||
|
||||
// NOTE: editPacketBuffer - is JUST the octcode/color and does not contain the packet header!
|
||||
void OctreeEditPacketSender::queueOctreeEditMessage(PacketType type, unsigned char* editPacketBuffer,
|
||||
void OctreeEditPacketSender::queueOctreeEditMessage (PacketType::Value type, unsigned char* editPacketBuffer,
|
||||
size_t length, qint64 satoshiCost) {
|
||||
|
||||
if (!_shouldSend) {
|
||||
|
|
|
@ -30,7 +30,7 @@ public:
|
|||
/// Queues a single edit message. Will potentially send a pending multi-command packet. Determines which server
|
||||
/// node or nodes the packet should be sent to. Can be called even before servers are known, in which case up to
|
||||
/// MaxPendingMessages will be buffered and processed when servers are known.
|
||||
void queueOctreeEditMessage(PacketType type, unsigned char* buffer, size_t length, qint64 satoshiCost = 0);
|
||||
void queueOctreeEditMessage (PacketType::Value type, unsigned char* buffer, size_t length, qint64 satoshiCost = 0);
|
||||
|
||||
/// Releases all queued messages even if those messages haven't filled an MTU packet. This will move the packed message
|
||||
/// packets onto the send queue. If running in threaded mode, the caller does not need to do any further processing to
|
||||
|
@ -81,7 +81,7 @@ public:
|
|||
|
||||
// you must override these...
|
||||
virtual char getMyNodeType() const = 0;
|
||||
virtual void adjustEditPacketForClockSkew(PacketType type,
|
||||
virtual void adjustEditPacketForClockSkew (PacketType::Value type,
|
||||
unsigned char* editPacketBuffer, size_t length, int clockSkew) { }
|
||||
|
||||
bool hasDestinationWalletUUID() const { return !_destinationWalletUUID.isNull(); }
|
||||
|
@ -99,7 +99,7 @@ signals:
|
|||
protected:
|
||||
bool _shouldSend;
|
||||
void queuePacketToNode(const QUuid& nodeID, unsigned char* buffer, size_t length, qint64 satoshiCost = 0);
|
||||
void queuePendingPacketToNodes(PacketType type, unsigned char* buffer, size_t length, qint64 satoshiCost = 0);
|
||||
void queuePendingPacketToNodes (PacketType::Value type, unsigned char* buffer, size_t length, qint64 satoshiCost = 0);
|
||||
void queuePacketToNodes(unsigned char* buffer, size_t length, qint64 satoshiCost = 0);
|
||||
void initializePacket(EditPacketBuffer& packetBuffer, PacketType::Value type, int nodeClockSkew);
|
||||
void releaseQueuedPacket(EditPacketBuffer& packetBuffer); // releases specific queued packet
|
||||
|
|
Loading…
Reference in a new issue