History

move ignore set handling to NodeList

Stephen Birarda committed 10 years ago

Commit 609900f1 parent 6b6513d7 files · +66 −37Browse files

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

Unified · Split

libraries/script-engine/src/UsersScriptingInterface.cpp+2−30
@@ -14,34 +14,6 @@ · 13 unmodified lines
14#include <NodeList.h>14#include <NodeList.h>
15 15
16void UsersScriptingInterface::ignore(const QUuid& nodeID) {16void UsersScriptingInterface::ignore(const QUuid& nodeID) {
17 // setup the ignore packet we send to all nodes (that currently handle it)17 // ask the NodeList to ignore this user (based on the session ID of their node)
18 // to ignore the data (audio/avatar) for this user18 DependencyManager::get<NodeList>()->ignoreNodeBySessionID(nodeID);
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 if (!nodeID.isNull() && 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::ignore called with an invalid ID or an ID which matches the current session ID.";
46 }
47}19}