From 6c701bb0f0124002fb8e57c6a1cec8cfec1394ab Mon Sep 17 00:00:00 2001 From: David Kelly Date: Mon, 16 Jan 2017 18:22:53 -0800 Subject: [PATCH 1/4] remove ignored avatars from PAL when they disconnect --- interface/resources/qml/hifi/Pal.qml | 4 ++++ interface/src/avatar/AvatarManager.cpp | 5 +++++ libraries/networking/src/NodeList.cpp | 12 ++++++++++++ libraries/networking/src/NodeList.h | 2 ++ .../script-engine/src/UsersScriptingInterface.h | 6 ++++++ scripts/system/pal.js | 8 +++++++- 6 files changed, 36 insertions(+), 1 deletion(-) diff --git a/interface/resources/qml/hifi/Pal.qml b/interface/resources/qml/hifi/Pal.qml index 3438baa217..a57e76f864 100644 --- a/interface/resources/qml/hifi/Pal.qml +++ b/interface/resources/qml/hifi/Pal.qml @@ -502,6 +502,10 @@ Rectangle { ignored = {}; gainSliderValueDB = {}; break; + case 'avatarDisconnected': + var sessionID = message.params[0]; + delete ignored[sessionID]; + break; default: console.log('Unrecognized message:', JSON.stringify(message)); } diff --git a/interface/src/avatar/AvatarManager.cpp b/interface/src/avatar/AvatarManager.cpp index 1f5726acba..848218a27e 100644 --- a/interface/src/avatar/AvatarManager.cpp +++ b/interface/src/avatar/AvatarManager.cpp @@ -261,6 +261,11 @@ void AvatarManager::handleRemovedAvatar(const AvatarSharedPointer& removedAvatar if (removalReason == KillAvatarReason::TheirAvatarEnteredYourBubble || removalReason == YourAvatarEnteredTheirBubble) { DependencyManager::get()->radiusIgnoreNodeBySessionID(avatar->getSessionUUID(), true); } + if (removalReason == KillAvatarReason::AvatarDisconnected) { + // remove from node sets, if present + DependencyManager::get()->maintainIgnoreMuteSets(avatar->getSessionUUID()); + DependencyManager::get()->avatarDisconnected(avatar->getSessionUUID()); + } _avatarFades.push_back(removedAvatar); } diff --git a/libraries/networking/src/NodeList.cpp b/libraries/networking/src/NodeList.cpp index 98a563c4e5..0ad31b70fe 100644 --- a/libraries/networking/src/NodeList.cpp +++ b/libraries/networking/src/NodeList.cpp @@ -847,6 +847,18 @@ void NodeList::ignoreNodeBySessionID(const QUuid& nodeID, bool ignoreEnabled) { } } +// removes this UUID from ignore and mute lists. +void NodeList::maintainIgnoreMuteSets(const QUuid& nodeID) { + // don't remove yourself, or nobody + if (!nodeID.isNull() && _sessionUUID != nodeID) { + QWriteLocker ignoredSetLocker{ &_ignoredSetLock }; + QWriteLocker personalMutedSetLocker{ &_personalMutedSetLock }; + _ignoredNodeIDs.unsafe_erase(nodeID); + _personalMutedNodeIDs.unsafe_erase(nodeID); + qCDebug(networking) << "removed" << nodeID.toString() << "from ignore/mute sets (if present)"; + } +} + bool NodeList::isIgnoringNode(const QUuid& nodeID) const { QReadLocker ignoredSetLocker{ &_ignoredSetLock }; return _ignoredNodeIDs.find(nodeID) != _ignoredNodeIDs.cend(); diff --git a/libraries/networking/src/NodeList.h b/libraries/networking/src/NodeList.h index 5c477303e2..4cbe3b1c3b 100644 --- a/libraries/networking/src/NodeList.h +++ b/libraries/networking/src/NodeList.h @@ -90,6 +90,8 @@ public: bool getRequestsDomainListData() { return _requestsDomainListData; } void setRequestsDomainListData(bool isRequesting); + void maintainIgnoreMuteSets(const QUuid& nodeID); + public slots: void reset(); void sendDomainServerCheckIn(); diff --git a/libraries/script-engine/src/UsersScriptingInterface.h b/libraries/script-engine/src/UsersScriptingInterface.h index 0b6b7855b5..2dcff02c77 100644 --- a/libraries/script-engine/src/UsersScriptingInterface.h +++ b/libraries/script-engine/src/UsersScriptingInterface.h @@ -139,6 +139,12 @@ signals: */ void usernameFromIDReply(const QString& nodeID, const QString& username, const QString& machineFingerprint); + /**jsdoc + * Notifies scripts that a user has disconnected from the domain + * @function Users.avatar.avatarDisconnected + */ + void avatarDisconnected(const QUuid& nodeID); + private: bool getRequestsDomainListData(); void setRequestsDomainListData(bool requests); diff --git a/scripts/system/pal.js b/scripts/system/pal.js index 5c5b84e3e8..ad7d2bd7b5 100644 --- a/scripts/system/pal.js +++ b/scripts/system/pal.js @@ -580,7 +580,11 @@ function onClicked() { } pal.setVisible(!pal.visible); } - +function avatarDisconnected(nodeID) { + // remove from the pal list + print("got avatarDisconnected for " + nodeID); + pal.sendToQml({method: 'avatarDisconnected', params: [nodeID]}); +} // // Button state. // @@ -593,6 +597,8 @@ button.clicked.connect(onClicked); pal.visibleChanged.connect(onVisibleChanged); pal.closed.connect(off); Users.usernameFromIDReply.connect(usernameFromIDReply); +Users.avatarDisconnected.connect(avatarDisconnected); + function clearLocalQMLDataAndClosePAL() { pal.sendToQml({ method: 'clearLocalQMLData' }); if (pal.visible) { From 6c07a9aece6920794cc0d69a5f60d585911877ae Mon Sep 17 00:00:00 2001 From: David Kelly Date: Mon, 16 Jan 2017 19:06:36 -0800 Subject: [PATCH 2/4] remove debuggng logspam --- libraries/networking/src/NodeList.cpp | 1 - scripts/system/pal.js | 1 - 2 files changed, 2 deletions(-) diff --git a/libraries/networking/src/NodeList.cpp b/libraries/networking/src/NodeList.cpp index 0ad31b70fe..8451b2c4a0 100644 --- a/libraries/networking/src/NodeList.cpp +++ b/libraries/networking/src/NodeList.cpp @@ -855,7 +855,6 @@ void NodeList::maintainIgnoreMuteSets(const QUuid& nodeID) { QWriteLocker personalMutedSetLocker{ &_personalMutedSetLock }; _ignoredNodeIDs.unsafe_erase(nodeID); _personalMutedNodeIDs.unsafe_erase(nodeID); - qCDebug(networking) << "removed" << nodeID.toString() << "from ignore/mute sets (if present)"; } } diff --git a/scripts/system/pal.js b/scripts/system/pal.js index ad7d2bd7b5..7ecce80480 100644 --- a/scripts/system/pal.js +++ b/scripts/system/pal.js @@ -582,7 +582,6 @@ function onClicked() { } function avatarDisconnected(nodeID) { // remove from the pal list - print("got avatarDisconnected for " + nodeID); pal.sendToQml({method: 'avatarDisconnected', params: [nodeID]}); } // From 2460e89a574613ab615c05c0d2ba283a6d2a5d71 Mon Sep 17 00:00:00 2001 From: David Kelly Date: Tue, 17 Jan 2017 09:53:04 -0800 Subject: [PATCH 3/4] CR feedback --- interface/src/avatar/AvatarManager.cpp | 2 +- libraries/networking/src/NodeList.cpp | 3 +-- libraries/networking/src/NodeList.h | 2 +- scripts/system/pal.js | 1 + 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/interface/src/avatar/AvatarManager.cpp b/interface/src/avatar/AvatarManager.cpp index 848218a27e..ef08a463f4 100644 --- a/interface/src/avatar/AvatarManager.cpp +++ b/interface/src/avatar/AvatarManager.cpp @@ -263,7 +263,7 @@ void AvatarManager::handleRemovedAvatar(const AvatarSharedPointer& removedAvatar } if (removalReason == KillAvatarReason::AvatarDisconnected) { // remove from node sets, if present - DependencyManager::get()->maintainIgnoreMuteSets(avatar->getSessionUUID()); + DependencyManager::get()->removeFromIgnoreMuteSets(avatar->getSessionUUID()); DependencyManager::get()->avatarDisconnected(avatar->getSessionUUID()); } _avatarFades.push_back(removedAvatar); diff --git a/libraries/networking/src/NodeList.cpp b/libraries/networking/src/NodeList.cpp index 8451b2c4a0..0fcd207b94 100644 --- a/libraries/networking/src/NodeList.cpp +++ b/libraries/networking/src/NodeList.cpp @@ -847,8 +847,7 @@ void NodeList::ignoreNodeBySessionID(const QUuid& nodeID, bool ignoreEnabled) { } } -// removes this UUID from ignore and mute lists. -void NodeList::maintainIgnoreMuteSets(const QUuid& nodeID) { +void NodeList::removeFromIgnoreMuteSets(const QUuid& nodeID) { // don't remove yourself, or nobody if (!nodeID.isNull() && _sessionUUID != nodeID) { QWriteLocker ignoredSetLocker{ &_ignoredSetLock }; diff --git a/libraries/networking/src/NodeList.h b/libraries/networking/src/NodeList.h index 4cbe3b1c3b..c4564c0889 100644 --- a/libraries/networking/src/NodeList.h +++ b/libraries/networking/src/NodeList.h @@ -90,7 +90,7 @@ public: bool getRequestsDomainListData() { return _requestsDomainListData; } void setRequestsDomainListData(bool isRequesting); - void maintainIgnoreMuteSets(const QUuid& nodeID); + void removeFromIgnoreMuteSets(const QUuid& nodeID); public slots: void reset(); diff --git a/scripts/system/pal.js b/scripts/system/pal.js index 7ecce80480..fb0d2b310b 100644 --- a/scripts/system/pal.js +++ b/scripts/system/pal.js @@ -620,6 +620,7 @@ Script.scriptEnding.connect(function () { Window.domainConnectionRefused.disconnect(clearLocalQMLDataAndClosePAL); Messages.unsubscribe(CHANNEL); Messages.messageReceived.disconnect(receiveMessage); + Users.avatarDisconnected.disconnect(avatarDisconnected); off(); }); From 9b1aaf3bfeb9a136a79396f75565eb02abd110a0 Mon Sep 17 00:00:00 2001 From: David Kelly Date: Tue, 17 Jan 2017 12:09:47 -0800 Subject: [PATCH 4/4] CR feedback --- interface/src/avatar/AvatarManager.cpp | 3 +-- libraries/script-engine/src/UsersScriptingInterface.h | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/interface/src/avatar/AvatarManager.cpp b/interface/src/avatar/AvatarManager.cpp index ef08a463f4..b0dc9922ff 100644 --- a/interface/src/avatar/AvatarManager.cpp +++ b/interface/src/avatar/AvatarManager.cpp @@ -260,8 +260,7 @@ void AvatarManager::handleRemovedAvatar(const AvatarSharedPointer& removedAvatar } if (removalReason == KillAvatarReason::TheirAvatarEnteredYourBubble || removalReason == YourAvatarEnteredTheirBubble) { DependencyManager::get()->radiusIgnoreNodeBySessionID(avatar->getSessionUUID(), true); - } - if (removalReason == KillAvatarReason::AvatarDisconnected) { + } else if (removalReason == KillAvatarReason::AvatarDisconnected) { // remove from node sets, if present DependencyManager::get()->removeFromIgnoreMuteSets(avatar->getSessionUUID()); DependencyManager::get()->avatarDisconnected(avatar->getSessionUUID()); diff --git a/libraries/script-engine/src/UsersScriptingInterface.h b/libraries/script-engine/src/UsersScriptingInterface.h index 2dcff02c77..758868ac63 100644 --- a/libraries/script-engine/src/UsersScriptingInterface.h +++ b/libraries/script-engine/src/UsersScriptingInterface.h @@ -142,6 +142,7 @@ signals: /**jsdoc * Notifies scripts that a user has disconnected from the domain * @function Users.avatar.avatarDisconnected + * @param {nodeID} NodeID The session ID of the avatar that has disconnected */ void avatarDisconnected(const QUuid& nodeID);