re-broadcast disconnects from domain-server

This commit is contained in:
Stephen Birarda 2015-11-12 17:23:39 -08:00
parent 1c9396d66e
commit e52e9be44c
3 changed files with 24 additions and 5 deletions

View file

@ -1832,7 +1832,21 @@ void DomainServer::processNodeDisconnectRequestPacket(QSharedPointer<NLPacket> p
// This packet has been matched to a source node and they're asking not to be in the domain anymore // This packet has been matched to a source node and they're asking not to be in the domain anymore
auto limitedNodeList = DependencyManager::get<LimitedNodeList>(); auto limitedNodeList = DependencyManager::get<LimitedNodeList>();
qDebug() << "Received a disconnect request from node with UUID" << packet->getSourceID(); const QUuid& nodeUUID = packet->getSourceID();
limitedNodeList->killNodeWithUUID(packet->getSourceID()); qDebug() << "Received a disconnect request from node with UUID" << nodeUUID;
if (limitedNodeList->nodeWithUUID(nodeUUID)) {
limitedNodeList->killNodeWithUUID(nodeUUID);
static auto removedNodePacket = NLPacket::create(PacketType::DomainServerRemovedNode, NUM_BYTES_RFC4122_UUID);
removedNodePacket->reset();
removedNodePacket->write(nodeUUID.toRfc4122());
// broadcast out the DomainServerRemovedNode message
limitedNodeList->eachNode([&limitedNodeList](const SharedNodePointer& otherNode){
limitedNodeList->sendUnreliablePacket(*removedNodePacket, *otherNode);
});
}
} }

View file

@ -35,6 +35,7 @@ class DomainHandler : public QObject {
public: public:
DomainHandler(QObject* parent = 0); DomainHandler(QObject* parent = 0);
void disconnect();
void clearSettings(); void clearSettings();
const QUuid& getUUID() const { return _uuid; } const QUuid& getUUID() const { return _uuid; }
@ -112,7 +113,6 @@ signals:
void settingsReceiveFail(); void settingsReceiveFail();
private: private:
void disconnect();
void sendDisconnectPacket(); void sendDisconnectPacket();
void hardReset(); void hardReset();

View file

@ -33,14 +33,19 @@ void ThreadedAssignment::setFinished(bool isFinished) {
if (_isFinished) { if (_isFinished) {
qDebug() << "ThreadedAssignment::setFinished(true) called - finishing up."; qDebug() << "ThreadedAssignment::setFinished(true) called - finishing up.";
auto& packetReceiver = DependencyManager::get<NodeList>()->getPacketReceiver(); auto nodeList = DependencyManager::get<NodeList>();
auto& packetReceiver = nodeList->getPacketReceiver();
// we should de-register immediately for any of our packets // we should de-register immediately for any of our packets
packetReceiver.unregisterListener(this); packetReceiver.unregisterListener(this);
// we should also tell the packet receiver to drop packets while we're cleaning up // we should also tell the packet receiver to drop packets while we're cleaning up
packetReceiver.setShouldDropPackets(true); packetReceiver.setShouldDropPackets(true);
// send a disconnect packet to the domain
nodeList->getDomainHandler().disconnect();
if (_domainServerTimer) { if (_domainServerTimer) {
// stop the domain-server check in timer by calling deleteLater so it gets cleaned up on NL thread // stop the domain-server check in timer by calling deleteLater so it gets cleaned up on NL thread