Showing the changes to libraries/script-engine/src/UsersScriptingInterface.cpp (1 of 6 files). Show all
Unified · Split
| @@ -0,0 +1,39 @@ | |||
| 1 | // | ||
| 2 | // UsersScriptingInterface.cpp | ||
| 3 | // libraries/script-engine/src | ||
| 4 | // | ||
| 5 | // Created by Stephen Birarda on 2016-07-11. | ||
| 6 | // Copyright 2016 High Fidelity, Inc. | ||
| 7 | // | ||
| 8 | // Distributed under the Apache License, Version 2.0. | ||
| 9 | // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html | ||
| 10 | // | ||
| 11 | |||
| 12 | #include "UsersScriptingInterface.h" | ||
| 13 | |||
| 14 | #include <NodeList.h> | ||
| 15 | |||
| 16 | void UsersScriptingInterface::ignore(const QUuid& nodeID) { | ||
| 17 | // setup the ignore packet we send to all nodes (that currently handle it) | ||
| 18 | // to ignore the data (audio/avatar) for this user | ||
| 19 | |||
| 20 | // enumerate the nodes to send a reliable ignore packet to each that can leverage it | ||
| 21 | auto nodeList = DependencyManager::get<NodeList>(); | ||
| 22 | |||
| 23 | nodeList->eachMatchingNode([&nodeID](const SharedNodePointer& node)->bool { | ||
| 24 | if (node->getType() != NodeType::AudioMixer || node->getType() != NodeType::AvatarMixer) { | ||
| 25 | return false; | ||
| 26 | } else { | ||
| 27 | return true; | ||
| 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 | // send off this ignore packet reliably to the matching node | ||
| 37 | nodeList->sendPacket(std::move(ignorePacket), *destinationNode); | ||
| 38 | }); | ||
| 39 | } | ||