It seems to be working, minus removing from list

This commit is contained in:
Zach Fox 2016-12-22 16:21:53 -08:00
parent 46e8bf5283
commit e26d347682
6 changed files with 28 additions and 14 deletions

View file

@ -250,16 +250,16 @@ void AudioMixer::handleNodePersonalMuteRequestPacket(QSharedPointer<ReceivedMess
<< uuidStringWithoutCurlyBraces(_uuid);
// Remove the session UUID to the set of personally muted ones for this listening node
sendingNode->_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<ReceivedMessage> 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(QSharedPointer<Receiv
// If we do have a matching node...
if (matchingNode) {
auto personalMuteStatusPacket = NLPacket::create(PacketType::NodePersonalMuteStatusReply, NUM_BYTES_RFC4122_UUID + sizeof(bool), true);
bool isMuted = sendingNode->isIgnoringNodeWithID(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);
}

View file

@ -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 {

View file

@ -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);

View file

@ -34,10 +34,10 @@ void UsersScriptingInterface::unignore(const QUuid& nodeID) {
DependencyManager::get<NodeList>()->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<NodeList>()->personalMuteNodeBySessionID(nodeID, enabled);
DependencyManager::get<NodeList>()->personalMuteNodeBySessionID(nodeID, muteEnabled);
}
void UsersScriptingInterface::requestPersonalMuteStatus(const QUuid& nodeID) {
@ -45,7 +45,6 @@ void UsersScriptingInterface::requestPersonalMuteStatus(const QUuid& nodeID) {
DependencyManager::get<NodeList>()->requestPersonalMuteStatus(nodeID);
}
void UsersScriptingInterface::kick(const QUuid& nodeID) {
// ask the NodeList to kick the user with the given session ID
DependencyManager::get<NodeList>()->kickNodeBySessionID(nodeID);

View file

@ -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.

View file

@ -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();
});