From 2f2940b7cce9c121e7f708d769b2090a69468231 Mon Sep 17 00:00:00 2001 From: howard-stearns Date: Thu, 22 Dec 2016 11:10:27 -0800 Subject: [PATCH] fixes --- assignment-client/src/avatars/AvatarMixer.cpp | 7 ++-- libraries/networking/src/Node.cpp | 2 +- libraries/networking/src/NodeList.cpp | 32 +++++++++++++++++++ libraries/networking/src/NodeList.h | 2 ++ .../src/UsersScriptingInterface.cpp | 6 ++++ .../src/UsersScriptingInterface.h | 1 + 6 files changed, 46 insertions(+), 4 deletions(-) diff --git a/assignment-client/src/avatars/AvatarMixer.cpp b/assignment-client/src/avatars/AvatarMixer.cpp index 64353e65b1..1192dfb200 100644 --- a/assignment-client/src/avatars/AvatarMixer.cpp +++ b/assignment-client/src/avatars/AvatarMixer.cpp @@ -49,6 +49,7 @@ AvatarMixer::AvatarMixer(ReceivedMessage& message) : packetReceiver.registerListener(PacketType::AvatarIdentity, this, "handleAvatarIdentityPacket"); packetReceiver.registerListener(PacketType::KillAvatar, this, "handleKillAvatarPacket"); packetReceiver.registerListener(PacketType::NodeIgnoreRequest, this, "handleNodeIgnoreRequestPacket"); + packetReceiver.registerListener(PacketType::NodeUnignoreRequest, this, "handleNodeUnignoreRequestPacket"); packetReceiver.registerListener(PacketType::RadiusIgnoreRequest, this, "handleRadiusIgnoreRequestPacket"); packetReceiver.registerListener(PacketType::RequestDomainListData, this, "handleRequestDomainListDataPacket"); @@ -208,8 +209,8 @@ void AvatarMixer::broadcastAvatarData() { // send extra data that is otherwise surpressed bool getsOutOfView = nodeData->getRequestsDomainListData(); - bool getsAnyIgnored = node->getCanKick(); - bool getsIgnoredByMe = getsAnyIgnored || nodeData->getRequestsDomainListData(); + bool getsIgnoredByMe = nodeData->getRequestsDomainListData(); + bool getsAnyIgnored = getsIgnoredByMe && node->getCanKick(); // 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 @@ -339,7 +340,7 @@ void AvatarMixer::broadcastAvatarData() { && (forceSend || otherNodeData->getIdentityChangeTimestamp() > _lastFrameTimestamp || distribution(generator) < IDENTITY_SEND_PROBABILITY)) { - qDebug() << "FIXME HRS sending identity to" << node->getUUID() << "from" << otherNode->getUUID(); + qDebug() << "FIXME HRS sending identity to" << node->getUUID() << "from" << otherNode->getUUID() << "gets mine/all/view:" << getsIgnoredByMe << getsAnyIgnored << getsOutOfView ; sendIdentityPacket(otherNodeData, node); } diff --git a/libraries/networking/src/Node.cpp b/libraries/networking/src/Node.cpp index 133c8adcab..0f3a6ee30d 100644 --- a/libraries/networking/src/Node.cpp +++ b/libraries/networking/src/Node.cpp @@ -118,7 +118,7 @@ void Node::removeIgnoredNode(const QUuid& otherNodeID) { // remove the session UUID from the set of ignored ones for this listening node _ignoredNodeIDSet.unsafe_erase(otherNodeID); } else { - qCWarning(networking) << "Node::addIgnoredNode called with null ID or ID of ignoring node."; + qCWarning(networking) << "Node::removeIgnoredNode called with null ID or ID of ignoring node."; } } diff --git a/libraries/networking/src/NodeList.cpp b/libraries/networking/src/NodeList.cpp index d10e954f5d..49c689b007 100644 --- a/libraries/networking/src/NodeList.cpp +++ b/libraries/networking/src/NodeList.cpp @@ -811,6 +811,38 @@ void NodeList::ignoreNodeBySessionID(const QUuid& nodeID) { } } +void NodeList::unignoreNodeBySessionID(const QUuid& nodeID) { + // enumerate the nodes to send a reliable ignore packet to each that can leverage it + if (!nodeID.isNull() && _sessionUUID != nodeID) { + eachMatchingNode([&nodeID](const SharedNodePointer& node)->bool { + if (node->getType() == NodeType::AudioMixer || node->getType() == NodeType::AvatarMixer) { + return true; + } else { + return false; + } + }, [&nodeID, this](const SharedNodePointer& destinationNode) { + // create a reliable NLPacket with space for the ignore UUID + auto ignorePacket = NLPacket::create(PacketType::NodeUnignoreRequest, NUM_BYTES_RFC4122_UUID, true); + + // write the node ID to the packet + ignorePacket->write(nodeID.toRfc4122()); + + qCDebug(networking) << "Sending packet to unignore node" << uuidStringWithoutCurlyBraces(nodeID); + + // send off this ignore packet reliably to the matching node + sendPacket(std::move(ignorePacket), *destinationNode); + }); + + QWriteLocker setLocker { &_ignoredSetLock }; // write lock for unsafe_erase + _ignoredNodeIDs.unsafe_erase(nodeID); + + emit unignoredNode(nodeID); + + } else { + qWarning() << "NodeList::unignoreNodeBySessionID called with an invalid ID or an ID which matches the current session ID."; + } +} + bool NodeList::isIgnoringNode(const QUuid& nodeID) const { QReadLocker setLocker { &_ignoredSetLock }; return _ignoredNodeIDs.find(nodeID) != _ignoredNodeIDs.cend(); diff --git a/libraries/networking/src/NodeList.h b/libraries/networking/src/NodeList.h index 9289d2c660..6d7026b562 100644 --- a/libraries/networking/src/NodeList.h +++ b/libraries/networking/src/NodeList.h @@ -77,6 +77,7 @@ public: void enableIgnoreRadius() { ignoreNodesInRadius(true); } void disableIgnoreRadius() { ignoreNodesInRadius(false); } void ignoreNodeBySessionID(const QUuid& nodeID); + void unignoreNodeBySessionID(const QUuid& nodeID); bool isIgnoringNode(const QUuid& nodeID) const; void kickNodeBySessionID(const QUuid& nodeID); @@ -112,6 +113,7 @@ signals: void limitOfSilentDomainCheckInsReached(); void receivedDomainServerList(); void ignoredNode(const QUuid& nodeID); + void unignoredNode(const QUuid& nodeID); void ignoreRadiusEnabledChanged(bool isIgnored); void usernameFromIDReply(const QString& nodeID, const QString& username, const QString& machineFingerprint); diff --git a/libraries/script-engine/src/UsersScriptingInterface.cpp b/libraries/script-engine/src/UsersScriptingInterface.cpp index 61120b6e89..b118423236 100644 --- a/libraries/script-engine/src/UsersScriptingInterface.cpp +++ b/libraries/script-engine/src/UsersScriptingInterface.cpp @@ -26,6 +26,12 @@ void UsersScriptingInterface::ignore(const QUuid& nodeID) { DependencyManager::get()->ignoreNodeBySessionID(nodeID); } +void UsersScriptingInterface::unignore(const QUuid& nodeID) { + // ask the NodeList to ignore this user (based on the session ID of their node) + DependencyManager::get()->unignoreNodeBySessionID(nodeID); +} + + void UsersScriptingInterface::kick(const QUuid& nodeID) { // ask the NodeList to kick the user with the given session ID DependencyManager::get()->kickNodeBySessionID(nodeID); diff --git a/libraries/script-engine/src/UsersScriptingInterface.h b/libraries/script-engine/src/UsersScriptingInterface.h index 0ebd8797c0..c8866376da 100644 --- a/libraries/script-engine/src/UsersScriptingInterface.h +++ b/libraries/script-engine/src/UsersScriptingInterface.h @@ -37,6 +37,7 @@ public slots: * @param {nodeID} nodeID The node or session ID of the user you want to ignore. */ void ignore(const QUuid& nodeID); + void unignore(const QUuid& nodeID); /**jsdoc * Kick another user.