From e26d3476822bf398d30279b0256ae3839d94038a Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Thu, 22 Dec 2016 16:21:53 -0800 Subject: [PATCH] It seems to be working, minus removing from list --- assignment-client/src/audio/AudioMixer.cpp | 11 ++++++----- libraries/networking/src/NodeList.cpp | 7 ++++--- libraries/networking/src/NodeList.h | 2 +- .../script-engine/src/UsersScriptingInterface.cpp | 5 ++--- .../script-engine/src/UsersScriptingInterface.h | 2 +- scripts/system/pal.js | 15 ++++++++++++++- 6 files changed, 28 insertions(+), 14 deletions(-) diff --git a/assignment-client/src/audio/AudioMixer.cpp b/assignment-client/src/audio/AudioMixer.cpp index f7ea49a642..3589c025f4 100644 --- a/assignment-client/src/audio/AudioMixer.cpp +++ b/assignment-client/src/audio/AudioMixer.cpp @@ -250,16 +250,16 @@ void AudioMixer::handleNodePersonalMuteRequestPacket(QSharedPointer_ignoredNodeIDSet.unsafe_erase(ignoredUUID); + //sendingNode->removeIgnoredNode(ignoredUUID); } } else { - qWarning() << "Node::addPersonalMutedNode called with null ID or ID of personal muting node."; + qWarning() << "Node::handlePersonalMutedNode called with null ID or ID of personal muting node."; } } void AudioMixer::handleNodePersonalMuteStatusRequestPacket(QSharedPointer packet, SharedNodePointer sendingNode) { // parse out the UUID whose personal mute status is being requested from the packet - QUuid UUIDToCheck = QUuid::fromRfc4122(message->readWithoutCopy(NUM_BYTES_RFC4122_UUID)); + QUuid UUIDToCheck = QUuid::fromRfc4122(packet->readWithoutCopy(NUM_BYTES_RFC4122_UUID)); if (!UUIDToCheck.isNull()) { // First, make sure we actually have a node with this UUID @@ -269,12 +269,13 @@ void AudioMixer::handleNodePersonalMuteStatusRequestPacket(QSharedPointerisIgnoringNodeWithID(UUIDToCheck); // write the node ID to the packet personalMuteStatusPacket->write(UUIDToCheck.toRfc4122()); - personalMuteStatusPacket->writePrimitive(isIgnoringNodeWithID(UUIDToCheck)); + personalMuteStatusPacket->writePrimitive(isMuted); - qCDebug(networking) << "Sending Personal Mute Status Request Packet for node" << uuidStringWithoutCurlyBraces(nodeID); + qDebug() << "Personal Mute Status: node" << uuidStringWithoutCurlyBraces(UUIDToCheck) << "mute status:" << isMuted; limitedNodeList->sendPacket(std::move(personalMuteStatusPacket), *sendingNode); } diff --git a/libraries/networking/src/NodeList.cpp b/libraries/networking/src/NodeList.cpp index f80dbad23d..ab63c81b9a 100644 --- a/libraries/networking/src/NodeList.cpp +++ b/libraries/networking/src/NodeList.cpp @@ -129,6 +129,7 @@ NodeList::NodeList(char newOwnerType, int socketListenPort, int dtlsListenPort) packetReceiver.registerListener(PacketType::DomainServerPathResponse, this, "processDomainServerPathResponse"); packetReceiver.registerListener(PacketType::DomainServerRemovedNode, this, "processDomainServerRemovedNode"); packetReceiver.registerListener(PacketType::UsernameFromIDReply, this, "processUsernameFromIDReply"); + packetReceiver.registerListener(PacketType::NodePersonalMuteStatusReply, this, "processPersonalMuteStatusReply"); } qint64 NodeList::sendStats(QJsonObject statsObject, HifiSockAddr destination) { @@ -875,7 +876,7 @@ void NodeList::maybeSendIgnoreSetToNode(SharedNodePointer newNode) { } } -void NodeList::personalMuteNodeBySessionID(const QUuid& nodeID, bool enabled) { +void NodeList::personalMuteNodeBySessionID(const QUuid& nodeID, bool muteEnabled) { // cannot personal mute yourself, or nobody if (!nodeID.isNull() && _sessionUUID != nodeID) { auto audioMixer = soloNodeOfType(NodeType::AudioMixer); @@ -885,9 +886,9 @@ void NodeList::personalMuteNodeBySessionID(const QUuid& nodeID, bool enabled) { // write the node ID to the packet personalMutePacket->write(nodeID.toRfc4122()); - personalMutePacket->writePrimitive(enabled); + personalMutePacket->writePrimitive(muteEnabled); - qCDebug(networking) << "Sending Personal Mute Packet to" << (enabled ? "mute" : "unmute") << "node" << uuidStringWithoutCurlyBraces(nodeID); + qCDebug(networking) << "Sending Personal Mute Packet to" << (muteEnabled ? "mute" : "unmute") << "node" << uuidStringWithoutCurlyBraces(nodeID); sendPacket(std::move(personalMutePacket), *audioMixer); } else { diff --git a/libraries/networking/src/NodeList.h b/libraries/networking/src/NodeList.h index 5b3f334366..b8022c2d72 100644 --- a/libraries/networking/src/NodeList.h +++ b/libraries/networking/src/NodeList.h @@ -79,7 +79,7 @@ public: void ignoreNodeBySessionID(const QUuid& nodeID); void unignoreNodeBySessionID(const QUuid& nodeID); bool isIgnoringNode(const QUuid& nodeID) const; - void personalMuteNodeBySessionID(const QUuid& nodeID, bool enabled); + void personalMuteNodeBySessionID(const QUuid& nodeID, bool muteEnabled); void kickNodeBySessionID(const QUuid& nodeID); void muteNodeBySessionID(const QUuid& nodeID); diff --git a/libraries/script-engine/src/UsersScriptingInterface.cpp b/libraries/script-engine/src/UsersScriptingInterface.cpp index e25a9603b6..0d6983a1e9 100644 --- a/libraries/script-engine/src/UsersScriptingInterface.cpp +++ b/libraries/script-engine/src/UsersScriptingInterface.cpp @@ -34,10 +34,10 @@ void UsersScriptingInterface::unignore(const QUuid& nodeID) { DependencyManager::get()->unignoreNodeBySessionID(nodeID); } -void UsersScriptingInterface::personalMute(const QUuid& nodeID, bool enabled) { +void UsersScriptingInterface::personalMute(const QUuid& nodeID, bool muteEnabled) { // ask the NodeList to mute the user with the given session ID // "Personal Mute" only applies one way and is not global - DependencyManager::get()->personalMuteNodeBySessionID(nodeID, enabled); + DependencyManager::get()->personalMuteNodeBySessionID(nodeID, muteEnabled); } void UsersScriptingInterface::requestPersonalMuteStatus(const QUuid& nodeID) { @@ -45,7 +45,6 @@ void UsersScriptingInterface::requestPersonalMuteStatus(const QUuid& nodeID) { DependencyManager::get()->requestPersonalMuteStatus(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 a7e6ec3a3e..31024defc6 100644 --- a/libraries/script-engine/src/UsersScriptingInterface.h +++ b/libraries/script-engine/src/UsersScriptingInterface.h @@ -45,7 +45,7 @@ public slots: * @param {nodeID} nodeID The node or session ID of the user you want to mute. * @param {bool} enable True for enabled; false for disabled. */ - void personalMute(const QUuid& nodeID, bool enabled); + void personalMute(const QUuid& nodeID, bool muteEnabled); /**jsdoc * Requests a bool containing whether you have given the given Avatar UUID. diff --git a/scripts/system/pal.js b/scripts/system/pal.js index 7f38857702..f69a4eb369 100644 --- a/scripts/system/pal.js +++ b/scripts/system/pal.js @@ -133,7 +133,10 @@ function populateUserList() { Users.requestUsernameFromID(id); } // Request personal mute status from AudioMixer - Users.requestPersonalMuteStatus(id); + // (as long as we're not requesting it for our own ID) + if (id) { + Users.requestPersonalMuteStatus(id); + } data.push(avatarPalDatum); if (id) { // No overlay for ourself. addAvatarNode(id); @@ -160,6 +163,14 @@ function usernameFromIDReply(id, username, machineFingerprint) { pal.sendToQml({ method: 'updateUsername', params: data }); } +// The function that handles the personal muted status from the AudioMixer +function personalMuteStatusReply(id, isPersonalMuted) { + var data = [id, isPersonalMuted]; + print('Personal Muted Status Data:', JSON.stringify(data)); + // Ship the data off to QML + pal.sendToQml({ method: 'updatePersonalMutedStatus', params: data }); +} + var pingPong = true; function updateOverlays() { var eye = Camera.position; @@ -330,6 +341,7 @@ button.clicked.connect(onClicked); pal.visibleChanged.connect(onVisibleChanged); pal.closed.connect(off); Users.usernameFromIDReply.connect(usernameFromIDReply); +Users.personalMuteStatusReply.connect(personalMuteStatusReply); function onIgnore(sessionId) { // make it go away in the usual way, since we'll still get data keeping it live // Why doesn't this work from .qml? (crashes) @@ -347,6 +359,7 @@ Script.scriptEnding.connect(function () { pal.closed.disconnect(off); Users.usernameFromIDReply.disconnect(usernameFromIDReply); Users.ignoredNode.disconnect(onIgnore); + Users.personalMuteStatusReply.disconnect(personalMuteStatusReply); off(); });