History

don't self-ignore from UsersScriptingInterface

Stephen Birarda committed 10 years ago

Commit d5af3231 parent 095bd7e1 file · +25 −20Browse files

Showing the changes to libraries/script-engine/src/UsersScriptingInterface.cpp (1 of 1 file). Show all

Unified · Split

libraries/script-engine/src/UsersScriptingInterface.cpp+25−20
@@ -20,24 +20,29 @@ void UsersScriptingInterface::ignore(const QUuid& nodeID) { · 19 unmodified lines
2020 // enumerate the nodes to send a reliable ignore packet to each that can leverage it
2121 auto nodeList = DependencyManager::get<NodeList>();
2222
23− nodeList->eachMatchingNode([&nodeID](const SharedNodePointer& node)->bool {
24− if (node->getType() == NodeType::AudioMixer || node->getType() == NodeType::AvatarMixer) {
25− return true;
26− } else {
27− return false;
28− }
29− }, [&nodeID, &nodeList](const SharedNodePointer& destinationNode) {
30− // create a reliable NLPacket with space for the ignore UUID
31− auto ignorePacket = NLPacket::create(PacketType::NodeIgnoreRequest, NUM_BYTES_RFC4122_UUID, true);
32−
33− // write the node ID to the packet
34− ignorePacket->write(nodeID.toRfc4122());
35−
36− qDebug() << "Sending packet to ignore node" << uuidStringWithoutCurlyBraces(nodeID);
37−
38− // send off this ignore packet reliably to the matching node
39− nodeList->sendPacket(std::move(ignorePacket), *destinationNode);
40− });
41−
42− emit ignoredNode(nodeID);
23+ if (nodeList->getSessionUUID() != nodeID) {
24+ nodeList->eachMatchingNode([&nodeID](const SharedNodePointer& node)->bool {
25+ if (node->getType() == NodeType::AudioMixer || node->getType() == NodeType::AvatarMixer) {
26+ return true;
27+ } else {
28+ return false;
29+ }
30+ }, [&nodeID, &nodeList](const SharedNodePointer& destinationNode) {
31+ // create a reliable NLPacket with space for the ignore UUID
32+ auto ignorePacket = NLPacket::create(PacketType::NodeIgnoreRequest, NUM_BYTES_RFC4122_UUID, true);
33+
34+ // write the node ID to the packet
35+ ignorePacket->write(nodeID.toRfc4122());
36+
37+ qDebug() << "Sending packet to ignore node" << uuidStringWithoutCurlyBraces(nodeID);
38+
39+ // send off this ignore packet reliably to the matching node
40+ nodeList->sendPacket(std::move(ignorePacket), *destinationNode);
41+ });
42+
43+ emit ignoredNode(nodeID);
44+ } else {
45+ qWarning() << "UsersScriptingInterface was asked to ignore a node ID which matches the current session ID, "
46+ << "but self-ignore has no meaning.";
47+ }
4348 }