mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 04:44:11 +02:00
add a scripting interface to ignore users
This commit is contained in:
parent
a134ac72de
commit
bb68e777e6
6 changed files with 72 additions and 3 deletions
|
@ -98,6 +98,7 @@
|
|||
#include <Tooltip.h>
|
||||
#include <udt/PacketHeaders.h>
|
||||
#include <UserActivityLogger.h>
|
||||
#include <UsersScriptingInterface.h>
|
||||
#include <recording/Deck.h>
|
||||
#include <recording/Recorder.h>
|
||||
#include <shared/StringHelpers.h>
|
||||
|
@ -454,6 +455,7 @@ bool setupEssentials(int& argc, char** argv) {
|
|||
DependencyManager::set<ResourceScriptingInterface>();
|
||||
DependencyManager::set<ToolbarScriptingInterface>();
|
||||
DependencyManager::set<UserActivityLoggerScriptingInterface>();
|
||||
DependencyManager::set<UsersScriptingInterface>();
|
||||
|
||||
#if defined(Q_OS_MAC) || defined(Q_OS_WIN)
|
||||
DependencyManager::set<SpeechRecognizer>();
|
||||
|
@ -4755,6 +4757,7 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEngine* scri
|
|||
scriptEngine->registerGlobalObject("Reticle", getApplicationCompositor().getReticleInterface());
|
||||
|
||||
scriptEngine->registerGlobalObject("UserActivityLogger", DependencyManager::get<UserActivityLoggerScriptingInterface>().data());
|
||||
scriptEngine->registerGlobalObject("Users", DependencyManager::get<UsersScriptingInterface>().data());
|
||||
}
|
||||
|
||||
bool Application::canAcceptURL(const QString& urlString) const {
|
||||
|
|
|
@ -82,6 +82,8 @@ void Node::handleNodeIgnoreRequest(QSharedPointer<ReceivedMessage> packet) {
|
|||
// parse out the UUID being ignored from the packet
|
||||
QUuid ignoredUUID = QUuid::fromRfc4122(packet->readWithoutCopy(NUM_BYTES_RFC4122_UUID));
|
||||
|
||||
qDebug() << "Adding" << ignoredUUID << "to ignore set for" << _uuid;
|
||||
|
||||
// add the session UUID to the set of ignored ones for this listening node
|
||||
_ignoredNodeIDSet.insert(ignoredUUID);
|
||||
}
|
||||
|
|
|
@ -40,8 +40,6 @@ const QSet<PacketType> NON_SOURCED_PACKETS = QSet<PacketType>()
|
|||
<< PacketType::ICEServerHeartbeatDenied << PacketType::AssignmentClientStatus << PacketType::StopNode
|
||||
<< PacketType::DomainServerRemovedNode;
|
||||
|
||||
const QSet<PacketType> RELIABLE_PACKETS = QSet<PacketType>();
|
||||
|
||||
PacketVersion versionForPacketType(PacketType packetType) {
|
||||
switch (packetType) {
|
||||
case PacketType::DomainList:
|
||||
|
|
|
@ -109,7 +109,6 @@ typedef char PacketVersion;
|
|||
|
||||
extern const QSet<PacketType> NON_VERIFIED_PACKETS;
|
||||
extern const QSet<PacketType> NON_SOURCED_PACKETS;
|
||||
extern const QSet<PacketType> RELIABLE_PACKETS;
|
||||
|
||||
PacketVersion versionForPacketType(PacketType packetType);
|
||||
QByteArray protocolVersionsSignature(); /// returns a unqiue signature for all the current protocols
|
||||
|
|
39
libraries/script-engine/src/UsersScriptingInterface.cpp
Normal file
39
libraries/script-engine/src/UsersScriptingInterface.cpp
Normal file
|
@ -0,0 +1,39 @@
|
|||
//
|
||||
// UsersScriptingInterface.cpp
|
||||
// libraries/script-engine/src
|
||||
//
|
||||
// Created by Stephen Birarda on 2016-07-11.
|
||||
// Copyright 2016 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#include "UsersScriptingInterface.h"
|
||||
|
||||
#include <NodeList.h>
|
||||
|
||||
void UsersScriptingInterface::ignore(const QUuid& nodeID) {
|
||||
// setup the ignore packet we send to all nodes (that currently handle it)
|
||||
// to ignore the data (audio/avatar) for this user
|
||||
|
||||
// enumerate the nodes to send a reliable ignore packet to each that can leverage it
|
||||
auto nodeList = DependencyManager::get<NodeList>();
|
||||
|
||||
nodeList->eachMatchingNode([&nodeID](const SharedNodePointer& node)->bool {
|
||||
if (node->getType() != NodeType::AudioMixer || node->getType() != NodeType::AvatarMixer) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}, [&nodeID, &nodeList](const SharedNodePointer& destinationNode) {
|
||||
// create a reliable NLPacket with space for the ignore UUID
|
||||
auto ignorePacket = NLPacket::create(PacketType::NodeIgnoreRequest, NUM_BYTES_RFC4122_UUID, true);
|
||||
|
||||
// write the node ID to the packet
|
||||
ignorePacket->write(nodeID.toRfc4122());
|
||||
|
||||
// send off this ignore packet reliably to the matching node
|
||||
nodeList->sendPacket(std::move(ignorePacket), *destinationNode);
|
||||
});
|
||||
}
|
28
libraries/script-engine/src/UsersScriptingInterface.h
Normal file
28
libraries/script-engine/src/UsersScriptingInterface.h
Normal file
|
@ -0,0 +1,28 @@
|
|||
//
|
||||
// UsersScriptingInterface.h
|
||||
// libraries/script-engine/src
|
||||
//
|
||||
// Created by Stephen Birarda on 2016-07-11.
|
||||
// Copyright 2016 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef hifi_UsersScriptingInterface_h
|
||||
#define hifi_UsersScriptingInterface_h
|
||||
|
||||
#include <DependencyManager.h>
|
||||
|
||||
class UsersScriptingInterface : public QObject, public Dependency {
|
||||
Q_OBJECT
|
||||
SINGLETON_DEPENDENCY
|
||||
|
||||
public slots:
|
||||
void ignore(const QUuid& nodeID);
|
||||
};
|
||||
|
||||
|
||||
#endif // hifi_UsersScriptingInterface_h
|
Loading…
Reference in a new issue