From 0ad9786f6b36f2422a8ae9195a10ec5524006bee Mon Sep 17 00:00:00 2001 From: howard-stearns Date: Wed, 21 Dec 2016 16:12:00 -0800 Subject: [PATCH] requestsDomainsListData --- assignment-client/src/avatars/AvatarMixer.cpp | 34 ++++++++++++++++--- assignment-client/src/avatars/AvatarMixer.h | 1 + .../src/avatars/AvatarMixerClientData.h | 3 ++ libraries/avatars/src/AvatarHashMap.cpp | 5 +-- libraries/networking/src/NodeList.cpp | 16 +++++++++ libraries/networking/src/NodeList.h | 3 ++ libraries/networking/src/udt/PacketHeaders.h | 3 +- .../src/UsersScriptingInterface.cpp | 7 ++++ .../src/UsersScriptingInterface.h | 6 ++++ scripts/system/pal.js | 2 ++ 10 files changed, 72 insertions(+), 8 deletions(-) diff --git a/assignment-client/src/avatars/AvatarMixer.cpp b/assignment-client/src/avatars/AvatarMixer.cpp index d8d0b10fea..2aa140470e 100644 --- a/assignment-client/src/avatars/AvatarMixer.cpp +++ b/assignment-client/src/avatars/AvatarMixer.cpp @@ -50,6 +50,7 @@ AvatarMixer::AvatarMixer(ReceivedMessage& message) : packetReceiver.registerListener(PacketType::KillAvatar, this, "handleKillAvatarPacket"); packetReceiver.registerListener(PacketType::NodeIgnoreRequest, this, "handleNodeIgnoreRequestPacket"); packetReceiver.registerListener(PacketType::RadiusIgnoreRequest, this, "handleRadiusIgnoreRequestPacket"); + packetReceiver.registerListener(PacketType::RequestDomainListData, this, "handleRequestDomainListDataPacket"); auto nodeList = DependencyManager::get(); connect(nodeList.data(), &NodeList::packetVersionMismatch, this, &AvatarMixer::handlePacketVersionMismatch); @@ -205,6 +206,11 @@ void AvatarMixer::broadcastAvatarData() { // use the data rate specifically for avatar data for FRD adjustment checks float avatarDataRateLastSecond = nodeData->getOutboundAvatarDataKbps(); + // send extra data that is otherwise surpressed + bool getsOutOfView = nodeData->getRequestsDomainListData(); + bool getsAnyIgnored = node->getCanKick(); + bool getsIgnoredByMe = getsAnyIgnored || nodeData->getRequestsDomainListData(); + // Check if it is time to adjust what we send this client based on the observed // bandwidth to this node. We do this once a second, which is also the window for // the bandwidth reported by node->getOutboundBandwidth(); @@ -275,14 +281,14 @@ void AvatarMixer::broadcastAvatarData() { // or that has ignored the viewing node if (!otherNode->getLinkedData() || otherNode->getUUID() == node->getUUID() - || node->isIgnoringNodeWithID(otherNode->getUUID()) - || otherNode->isIgnoringNodeWithID(node->getUUID())) { + || (node->isIgnoringNodeWithID(otherNode->getUUID()) && !getsIgnoredByMe) + || (otherNode->isIgnoringNodeWithID(node->getUUID()) && !getsAnyIgnored)) { return false; } else { AvatarMixerClientData* otherData = reinterpret_cast(otherNode->getLinkedData()); AvatarMixerClientData* nodeData = reinterpret_cast(node->getLinkedData()); // Check to see if the space bubble is enabled - if (node->isIgnoreRadiusEnabled() || otherNode->isIgnoreRadiusEnabled()) { + if ((node->isIgnoreRadiusEnabled() && !getsIgnoredByMe) || (otherNode->isIgnoreRadiusEnabled() && !getsAnyIgnored)) { // Define the minimum bubble size static const glm::vec3 minBubbleSize = glm::vec3(0.3f, 1.3f, 0.3f); // Define the scale of the box for the current node @@ -333,7 +339,7 @@ void AvatarMixer::broadcastAvatarData() { && (forceSend || otherNodeData->getIdentityChangeTimestamp() > _lastFrameTimestamp || distribution(generator) < IDENTITY_SEND_PROBABILITY)) { - + qDebug() << "FIXME HRS sending identity to" << node->getUUID() << "from" << otherNode->getUUID(); sendIdentityPacket(otherNodeData, node); } @@ -349,6 +355,7 @@ void AvatarMixer::broadcastAvatarData() { maxAvatarDistanceThisFrame = std::max(maxAvatarDistanceThisFrame, distanceToAvatar); if (distanceToAvatar != 0.0f + && !getsOutOfView && distribution(generator) > (nodeData->getFullRateDistance() / distanceToAvatar)) { return; } @@ -388,7 +395,7 @@ void AvatarMixer::broadcastAvatarData() { AABox otherNodeBox(otherNodeData->getGlobalBoundingBoxCorner(), otherNodeBoxScale); AvatarData::AvatarDataDetail detail; - if (!nodeData->otherAvatarInView(otherNodeBox)) { + if (!nodeData->otherAvatarInView(otherNodeBox) && !getsOutOfView) { detail = AvatarData::MinimumData; nodeData->incrementAvatarOutOfView(); } else { @@ -396,6 +403,7 @@ void AvatarMixer::broadcastAvatarData() { ? AvatarData::SendAllData : AvatarData::IncludeSmallData; nodeData->incrementAvatarInView(); } + //qDebug() << "FIXME HRS sending" << detail << "to" << node->getUUID() << "from" << otherNode->getUUID(); numAvatarDataBytes += avatarPacketList->write(otherNode->getUUID().toRfc4122()); numAvatarDataBytes += avatarPacketList->write(otherAvatar.toByteArray(detail)); @@ -527,6 +535,22 @@ void AvatarMixer::handleViewFrustumPacket(QSharedPointer messag } } +void AvatarMixer::handleRequestDomainListDataPacket(QSharedPointer message, SharedNodePointer senderNode) { + auto nodeList = DependencyManager::get(); + nodeList->getOrCreateLinkedData(senderNode); + qDebug() << "HRS FIXME received requestDomainListData packet from" << senderNode->getUUID(); + + if (senderNode->getLinkedData()) { + AvatarMixerClientData* nodeData = dynamic_cast(senderNode->getLinkedData()); + if (nodeData != nullptr) { + bool isRequesting; + message->readPrimitive(&isRequesting); + qDebug() << "HRS FIXME handling requestDomainListData packet" << isRequesting << "from" << nodeData->getNodeID(); + nodeData->setRequestDomainListData(isRequesting); + } + } +} + void AvatarMixer::handleAvatarDataPacket(QSharedPointer message, SharedNodePointer senderNode) { auto nodeList = DependencyManager::get(); nodeList->updateNodeWithDataFromPacket(message, senderNode); diff --git a/assignment-client/src/avatars/AvatarMixer.h b/assignment-client/src/avatars/AvatarMixer.h index 521fe72f39..66cf9470c0 100644 --- a/assignment-client/src/avatars/AvatarMixer.h +++ b/assignment-client/src/avatars/AvatarMixer.h @@ -42,6 +42,7 @@ private slots: void handleKillAvatarPacket(QSharedPointer message); void handleNodeIgnoreRequestPacket(QSharedPointer message, SharedNodePointer senderNode); void handleRadiusIgnoreRequestPacket(QSharedPointer packet, SharedNodePointer sendingNode); + void handleRequestDomainListDataPacket(QSharedPointer message, SharedNodePointer senderNode); void domainSettingsRequestComplete(); void handlePacketVersionMismatch(PacketType type, const HifiSockAddr& senderSockAddr, const QUuid& senderUUID); diff --git a/assignment-client/src/avatars/AvatarMixerClientData.h b/assignment-client/src/avatars/AvatarMixerClientData.h index 78a30d8206..462968eb37 100644 --- a/assignment-client/src/avatars/AvatarMixerClientData.h +++ b/assignment-client/src/avatars/AvatarMixerClientData.h @@ -101,6 +101,8 @@ public: void incrementAvatarOutOfView() { _recentOtherAvatarsOutOfView++; } const QString& getBaseDisplayName() { return _baseDisplayName; } void setBaseDisplayName(const QString& baseDisplayName) { _baseDisplayName = baseDisplayName; } + bool getRequestsDomainListData() { return _requestsDomainListData; } + void setRequestDomainListData(bool requesting) { _requestsDomainListData = requesting; } private: AvatarSharedPointer _avatar { new AvatarData() }; @@ -129,6 +131,7 @@ private: int _recentOtherAvatarsInView { 0 }; int _recentOtherAvatarsOutOfView { 0 }; QString _baseDisplayName{}; // The santized key used in determinging unique sessionDisplayName, so that we can remove from dictionary. + bool _requestsDomainListData { false }; }; #endif // hifi_AvatarMixerClientData_h diff --git a/libraries/avatars/src/AvatarHashMap.cpp b/libraries/avatars/src/AvatarHashMap.cpp index 8871769261..c0aafa7f2b 100644 --- a/libraries/avatars/src/AvatarHashMap.cpp +++ b/libraries/avatars/src/AvatarHashMap.cpp @@ -112,7 +112,7 @@ void AvatarHashMap::processAvatarDataPacket(QSharedPointer mess // make sure this isn't our own avatar data or for a previously ignored node auto nodeList = DependencyManager::get(); - if (sessionUUID != _lastOwnerSessionUUID && !nodeList->isIgnoringNode(sessionUUID)) { + if (sessionUUID != _lastOwnerSessionUUID && (!nodeList->isIgnoringNode(sessionUUID) || nodeList->getRequestsDomainListData())) { auto avatar = newOrExistingAvatar(sessionUUID, sendingNode); // have the matching (or new) avatar parse the data from the packet @@ -145,7 +145,8 @@ void AvatarHashMap::processAvatarIdentityPacket(QSharedPointer identity.uuid = EMPTY; } } - if (!nodeList->isIgnoringNode(identity.uuid)) { + qDebug() << "FIXME HRS processing identity packet regarding" << identity.uuid << "ignoring:" << nodeList->isIgnoringNode(identity.uuid) << "reqestsDomainList:" << nodeList->getRequestsDomainListData(); + if (!nodeList->isIgnoringNode(identity.uuid) || nodeList->getRequestsDomainListData()) { // mesh URL for a UUID, find avatar in our list auto avatar = newOrExistingAvatar(identity.uuid, sendingNode); avatar->processAvatarIdentity(identity); diff --git a/libraries/networking/src/NodeList.cpp b/libraries/networking/src/NodeList.cpp index 27b3e11fda..d10e954f5d 100644 --- a/libraries/networking/src/NodeList.cpp +++ b/libraries/networking/src/NodeList.cpp @@ -930,3 +930,19 @@ void NodeList::processUsernameFromIDReply(QSharedPointer messag emit usernameFromIDReply(nodeUUIDString, username, machineFingerprintString); } + +void NodeList::setRequestsDomainListData(bool isRequesting) { + // Tell the avatar mixer whether I want to receive any additional data to which I might be entitiled . + if (_requestsDomainListData == isRequesting) { + return; + } + eachMatchingNode([](const SharedNodePointer& node)->bool { + return node->getType() == NodeType::AvatarMixer; + }, [this, isRequesting](const SharedNodePointer& destinationNode) { + auto packet = NLPacket::create(PacketType::RequestDomainListData, sizeof(bool), true); // reliable + packet->writePrimitive(isRequesting); + sendPacket(std::move(packet), *destinationNode); + qDebug() << "HRS FIXME sending requestDomainListData packet" << isRequesting; + }); + _requestsDomainListData = isRequesting; +} \ No newline at end of file diff --git a/libraries/networking/src/NodeList.h b/libraries/networking/src/NodeList.h index d3f04cedd8..9289d2c660 100644 --- a/libraries/networking/src/NodeList.h +++ b/libraries/networking/src/NodeList.h @@ -82,6 +82,8 @@ public: void kickNodeBySessionID(const QUuid& nodeID); void muteNodeBySessionID(const QUuid& nodeID); void requestUsernameFromSessionID(const QUuid& nodeID); + bool getRequestsDomainListData() { return _requestsDomainListData; } + void setRequestsDomainListData(bool isRequesting); public slots: void reset(); @@ -153,6 +155,7 @@ private: HifiSockAddr _assignmentServerSocket; bool _isShuttingDown { false }; QTimer _keepAlivePingTimer; + bool _requestsDomainListData; mutable QReadWriteLock _ignoredSetLock; tbb::concurrent_unordered_set _ignoredNodeIDs; diff --git a/libraries/networking/src/udt/PacketHeaders.h b/libraries/networking/src/udt/PacketHeaders.h index 162e565b83..ed40f1bdad 100644 --- a/libraries/networking/src/udt/PacketHeaders.h +++ b/libraries/networking/src/udt/PacketHeaders.h @@ -104,7 +104,8 @@ public: UsernameFromIDRequest, UsernameFromIDReply, ViewFrustum, - LAST_PACKET_TYPE = ViewFrustum + RequestDomainListData, + LAST_PACKET_TYPE = ViewFrustum // FIXME! RequestDomainListData }; }; diff --git a/libraries/script-engine/src/UsersScriptingInterface.cpp b/libraries/script-engine/src/UsersScriptingInterface.cpp index 191952e354..61120b6e89 100644 --- a/libraries/script-engine/src/UsersScriptingInterface.cpp +++ b/libraries/script-engine/src/UsersScriptingInterface.cpp @@ -61,3 +61,10 @@ void UsersScriptingInterface::disableIgnoreRadius() { bool UsersScriptingInterface::getIgnoreRadiusEnabled() { return DependencyManager::get()->getIgnoreRadiusEnabled(); } + +bool UsersScriptingInterface::getRequestsDomainListData() { + return DependencyManager::get()->getRequestsDomainListData(); +} +void UsersScriptingInterface::setRequestsDomainListData(bool isRequesting) { + DependencyManager::get()->setRequestsDomainListData(isRequesting); +} \ No newline at end of file diff --git a/libraries/script-engine/src/UsersScriptingInterface.h b/libraries/script-engine/src/UsersScriptingInterface.h index 855dc06c11..0ebd8797c0 100644 --- a/libraries/script-engine/src/UsersScriptingInterface.h +++ b/libraries/script-engine/src/UsersScriptingInterface.h @@ -24,6 +24,7 @@ class UsersScriptingInterface : public QObject, public Dependency { SINGLETON_DEPENDENCY Q_PROPERTY(bool canKick READ getCanKick) + Q_PROPERTY(bool requestsDomainListData READ getRequestsDomainListData WRITE setRequestsDomainListData) public: UsersScriptingInterface(); @@ -105,6 +106,11 @@ signals: * @function Users.usernameFromIDReply */ void usernameFromIDReply(const QString& nodeID, const QString& username, const QString& machineFingerprint); + +private: + bool getRequestsDomainListData(); + void setRequestsDomainListData(bool requests); + bool _requestsDomainListData; }; diff --git a/scripts/system/pal.js b/scripts/system/pal.js index 9c23e1f775..77f939d2c5 100644 --- a/scripts/system/pal.js +++ b/scripts/system/pal.js @@ -252,9 +252,11 @@ function off() { } triggerMapping.disable(); // It's ok if we disable twice. removeOverlays(); + Users.requestsDomainListData = false; } function onClicked() { if (!pal.visible) { + Users.requestsDomainListData = true; populateUserList(); pal.raise(); isWired = true;