mirror of
https://github.com/overte-org/overte.git
synced 2025-04-19 15:43:50 +02:00
add a kick request packet and send from NL
This commit is contained in:
parent
94b97e8119
commit
7e6dbf2d1a
6 changed files with 37 additions and 3 deletions
|
@ -727,7 +727,7 @@ void NodeList::ignoreNodeBySessionID(const QUuid& nodeID) {
|
|||
emit ignoredNode(nodeID);
|
||||
|
||||
} else {
|
||||
qWarning() << "UsersScriptingInterface::ignore called with an invalid ID or an ID which matches the current session ID.";
|
||||
qWarning() << "NodeList::ignoreNodeBySessionID called with an invalid ID or an ID which matches the current session ID.";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -759,3 +759,28 @@ void NodeList::maybeSendIgnoreSetToNode(SharedNodePointer newNode) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
void NodeList::kickNodeBySessionID(const QUuid& nodeID) {
|
||||
// send a request to domain-server to kick the node with the given session ID
|
||||
// the domain-server will handle the persistence of the kick (via username or IP)
|
||||
|
||||
if (!nodeID.isNull() && _sessionUUID != nodeID ) {
|
||||
if (getThisNodeCanKick()) {
|
||||
// setup the packet
|
||||
auto kickPacket = NLPacket::create(PacketType::NodeKickRequest, NUM_BYTES_RFC4122_UUID, true);
|
||||
|
||||
// write the node ID to the packet
|
||||
kickPacket->write(nodeID.toRfc4122());
|
||||
|
||||
qDebug() << "Sending packet to kick node" << uuidStringWithoutCurlyBraces(nodeID);
|
||||
|
||||
sendPacket(std::move(kickPacket), _domainHandler.getSockAddr());
|
||||
} else {
|
||||
qWarning() << "You do not have permissions to kick in this domain."
|
||||
<< "Request to kick node" << uuidStringWithoutCurlyBraces(nodeID) << "will not be sent";
|
||||
}
|
||||
} else {
|
||||
qWarning() << "NodeList::kickNodeBySessionID called with an invalid ID or an ID which matches the current session ID.";
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -73,6 +73,8 @@ public:
|
|||
void ignoreNodeBySessionID(const QUuid& nodeID);
|
||||
bool isIgnoringNode(const QUuid& nodeID) const;
|
||||
|
||||
void kickNodeBySessionID(const QUuid& nodeID);
|
||||
|
||||
public slots:
|
||||
void reset();
|
||||
void sendDomainServerCheckIn();
|
||||
|
|
|
@ -26,7 +26,7 @@ const QSet<PacketType> NON_VERIFIED_PACKETS = QSet<PacketType>()
|
|||
<< PacketType::NodeJsonStats << PacketType::EntityQuery
|
||||
<< PacketType::OctreeDataNack << PacketType::EntityEditNack
|
||||
<< PacketType::DomainListRequest << PacketType::StopNode
|
||||
<< PacketType::DomainDisconnectRequest;
|
||||
<< PacketType::DomainDisconnectRequest << PacketType::NodeKickRequest;
|
||||
|
||||
const QSet<PacketType> NON_SOURCED_PACKETS = QSet<PacketType>()
|
||||
<< PacketType::StunResponse << PacketType::CreateAssignment << PacketType::RequestAssignment
|
||||
|
|
|
@ -98,7 +98,8 @@ public:
|
|||
NegotiateAudioFormat,
|
||||
SelectedAudioFormat,
|
||||
MoreEntityShapes,
|
||||
LAST_PACKET_TYPE = MoreEntityShapes
|
||||
NodeKickRequest,
|
||||
LAST_PACKET_TYPE = NodeKickRequest
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -17,3 +17,8 @@ void UsersScriptingInterface::ignore(const QUuid& nodeID) {
|
|||
// ask the NodeList to ignore this user (based on the session ID of their node)
|
||||
DependencyManager::get<NodeList>()->ignoreNodeBySessionID(nodeID);
|
||||
}
|
||||
|
||||
void UsersScriptingInterface::kick(const QUuid& nodeID) {
|
||||
// ask the NodeList to kick the user with the given session ID
|
||||
DependencyManager::get<NodeList>()->kickNodeBySessionID(nodeID);
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ class UsersScriptingInterface : public QObject, public Dependency {
|
|||
|
||||
public slots:
|
||||
void ignore(const QUuid& nodeID);
|
||||
void kick(const QUuid& nodeID);
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue