mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 11:42:55 +02:00
only broadcast removed node messages to interested nodes
This commit is contained in:
parent
b47aadff2b
commit
f4cf1c0291
1 changed files with 13 additions and 2 deletions
|
@ -1835,14 +1835,25 @@ void DomainServer::processNodeDisconnectRequestPacket(QSharedPointer<NLPacket> p
|
||||||
|
|
||||||
qDebug() << "Received a disconnect request from node with UUID" << nodeUUID;
|
qDebug() << "Received a disconnect request from node with UUID" << nodeUUID;
|
||||||
|
|
||||||
if (limitedNodeList->killNodeWithUUID(nodeUUID)) {
|
// we want to check what type this node was before going to kill it so that we can avoid sending the RemovedNode
|
||||||
|
// packet to nodes that don't care about this type
|
||||||
|
auto node = limitedNodeList->nodeWithUUID(nodeUUID);
|
||||||
|
|
||||||
|
if (node) {
|
||||||
|
auto nodeType = node->getType();
|
||||||
|
limitedNodeList->killNodeWithUUID(nodeUUID);
|
||||||
|
|
||||||
static auto removedNodePacket = NLPacket::create(PacketType::DomainServerRemovedNode, NUM_BYTES_RFC4122_UUID);
|
static auto removedNodePacket = NLPacket::create(PacketType::DomainServerRemovedNode, NUM_BYTES_RFC4122_UUID);
|
||||||
|
|
||||||
removedNodePacket->reset();
|
removedNodePacket->reset();
|
||||||
removedNodePacket->write(nodeUUID.toRfc4122());
|
removedNodePacket->write(nodeUUID.toRfc4122());
|
||||||
|
|
||||||
// broadcast out the DomainServerRemovedNode message
|
// broadcast out the DomainServerRemovedNode message
|
||||||
limitedNodeList->eachNode([&limitedNodeList](const SharedNodePointer& otherNode){
|
limitedNodeList->eachMatchingNode([&nodeType](const SharedNodePointer& otherNode) -> bool {
|
||||||
|
// only send the removed node packet to nodes that care about the type of node this was
|
||||||
|
auto nodeLinkedData = dynamic_cast<DomainServerNodeData*>(otherNode->getLinkedData());
|
||||||
|
return (nodeLinkedData != nullptr) && nodeLinkedData->getNodeInterestSet().contains(nodeType);
|
||||||
|
}, [&limitedNodeList](const SharedNodePointer& otherNode){
|
||||||
limitedNodeList->sendUnreliablePacket(*removedNodePacket, *otherNode);
|
limitedNodeList->sendUnreliablePacket(*removedNodePacket, *otherNode);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue