This commit is contained in:
howard-stearns 2016-12-22 11:10:27 -08:00 committed by Zach Fox
parent 344272f24a
commit 2f2940b7cc
6 changed files with 46 additions and 4 deletions

View file

@ -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);
}

View file

@ -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.";
}
}

View file

@ -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();

View file

@ -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);

View file

@ -26,6 +26,12 @@ void UsersScriptingInterface::ignore(const QUuid& nodeID) {
DependencyManager::get<NodeList>()->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<NodeList>()->unignoreNodeBySessionID(nodeID);
}
void UsersScriptingInterface::kick(const QUuid& nodeID) {
// ask the NodeList to kick the user with the given session ID
DependencyManager::get<NodeList>()->kickNodeBySessionID(nodeID);

View file

@ -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.