mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 19:59:28 +02:00
send disconnect packet from node when leaving domain
This commit is contained in:
parent
0a64242160
commit
8bdb81d832
4 changed files with 30 additions and 8 deletions
|
@ -46,7 +46,13 @@ DomainHandler::DomainHandler(QObject* parent) :
|
||||||
connect(this, &DomainHandler::completedSocketDiscovery, &_icePeer, &NetworkPeer::stopPingTimer);
|
connect(this, &DomainHandler::completedSocketDiscovery, &_icePeer, &NetworkPeer::stopPingTimer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DomainHandler::clearConnectionInfo() {
|
void DomainHandler::disconnect() {
|
||||||
|
// if we're currently connected to a domain, send a disconnect packet on our way out
|
||||||
|
if (_isConnected) {
|
||||||
|
sendDisconnectPacket();
|
||||||
|
}
|
||||||
|
|
||||||
|
// clear member variables that hold the connection state to a domain
|
||||||
_uuid = QUuid();
|
_uuid = QUuid();
|
||||||
_connectionToken = QUuid();
|
_connectionToken = QUuid();
|
||||||
|
|
||||||
|
@ -60,6 +66,18 @@ void DomainHandler::clearConnectionInfo() {
|
||||||
setIsConnected(false);
|
setIsConnected(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DomainHandler::sendDisconnectPacket() {
|
||||||
|
// The DomainDisconnect packet is not verified - we're relying on the eventual addition of DTLS to the
|
||||||
|
// domain-server connection to stop greifing here
|
||||||
|
|
||||||
|
// construct the disconnect packet once (an empty packet but sourced with our current session UUID)
|
||||||
|
static auto disconnectPacket = NLPacket::create(PacketType::DomainDisconnect, 0);
|
||||||
|
|
||||||
|
// send the disconnect packet to the current domain server
|
||||||
|
auto nodeList = DependencyManager::get<NodeList>();
|
||||||
|
nodeList->sendUnreliablePacket(*disconnectPacket, _sockAddr);
|
||||||
|
}
|
||||||
|
|
||||||
void DomainHandler::clearSettings() {
|
void DomainHandler::clearSettings() {
|
||||||
_settingsObject = QJsonObject();
|
_settingsObject = QJsonObject();
|
||||||
_failedSettingsRequests = 0;
|
_failedSettingsRequests = 0;
|
||||||
|
@ -67,7 +85,7 @@ void DomainHandler::clearSettings() {
|
||||||
|
|
||||||
void DomainHandler::softReset() {
|
void DomainHandler::softReset() {
|
||||||
qCDebug(networking) << "Resetting current domain connection information.";
|
qCDebug(networking) << "Resetting current domain connection information.";
|
||||||
clearConnectionInfo();
|
disconnect();
|
||||||
clearSettings();
|
clearSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,6 @@ class DomainHandler : public QObject {
|
||||||
public:
|
public:
|
||||||
DomainHandler(QObject* parent = 0);
|
DomainHandler(QObject* parent = 0);
|
||||||
|
|
||||||
void clearConnectionInfo();
|
|
||||||
void clearSettings();
|
void clearSettings();
|
||||||
|
|
||||||
const QUuid& getUUID() const { return _uuid; }
|
const QUuid& getUUID() const { return _uuid; }
|
||||||
|
@ -113,6 +112,8 @@ signals:
|
||||||
void settingsReceiveFail();
|
void settingsReceiveFail();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void disconnect();
|
||||||
|
void sendDisconnectPacket();
|
||||||
void hardReset();
|
void hardReset();
|
||||||
|
|
||||||
QUuid _uuid;
|
QUuid _uuid;
|
||||||
|
|
|
@ -19,7 +19,8 @@
|
||||||
const QSet<PacketType> NON_VERIFIED_PACKETS = QSet<PacketType>()
|
const QSet<PacketType> NON_VERIFIED_PACKETS = QSet<PacketType>()
|
||||||
<< PacketType::NodeJsonStats << PacketType::EntityQuery
|
<< PacketType::NodeJsonStats << PacketType::EntityQuery
|
||||||
<< PacketType::OctreeDataNack << PacketType::EntityEditNack
|
<< PacketType::OctreeDataNack << PacketType::EntityEditNack
|
||||||
<< PacketType::DomainListRequest << PacketType::StopNode;
|
<< PacketType::DomainListRequest << PacketType::StopNode
|
||||||
|
<< PacketType::DomainDisconnect;
|
||||||
|
|
||||||
const QSet<PacketType> NON_SOURCED_PACKETS = QSet<PacketType>()
|
const QSet<PacketType> NON_SOURCED_PACKETS = QSet<PacketType>()
|
||||||
<< PacketType::StunResponse << PacketType::CreateAssignment << PacketType::RequestAssignment
|
<< PacketType::StunResponse << PacketType::CreateAssignment << PacketType::RequestAssignment
|
||||||
|
@ -30,7 +31,8 @@ const QSet<PacketType> NON_SOURCED_PACKETS = QSet<PacketType>()
|
||||||
<< PacketType::DomainSettingsRequest << PacketType::DomainSettings
|
<< PacketType::DomainSettingsRequest << PacketType::DomainSettings
|
||||||
<< PacketType::ICEServerPeerInformation << PacketType::ICEServerQuery << PacketType::ICEServerHeartbeat
|
<< PacketType::ICEServerPeerInformation << PacketType::ICEServerQuery << PacketType::ICEServerHeartbeat
|
||||||
<< PacketType::ICEPing << PacketType::ICEPingReply
|
<< PacketType::ICEPing << PacketType::ICEPingReply
|
||||||
<< PacketType::AssignmentClientStatus << PacketType::StopNode;
|
<< PacketType::AssignmentClientStatus << PacketType::StopNode
|
||||||
|
<< PacketType::DomainServerRemovedNode;
|
||||||
|
|
||||||
const QSet<PacketType> RELIABLE_PACKETS = QSet<PacketType>();
|
const QSet<PacketType> RELIABLE_PACKETS = QSet<PacketType>();
|
||||||
|
|
||||||
|
@ -48,8 +50,8 @@ PacketVersion versionForPacketType(PacketType packetType) {
|
||||||
}
|
}
|
||||||
|
|
||||||
uint qHash(const PacketType& key, uint seed) {
|
uint qHash(const PacketType& key, uint seed) {
|
||||||
// seems odd that Qt couldn't figure out this cast itself, but this fixes a compile error after switch to
|
// seems odd that Qt couldn't figure out this cast itself, but this fixes a compile error after switch
|
||||||
// strongly typed enum for PacketType
|
// to strongly typed enum for PacketType
|
||||||
return qHash((quint8) key, seed);
|
return qHash((quint8) key, seed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -86,7 +86,8 @@ public:
|
||||||
AssetUploadReply,
|
AssetUploadReply,
|
||||||
AssetGetInfo,
|
AssetGetInfo,
|
||||||
AssetGetInfoReply,
|
AssetGetInfoReply,
|
||||||
NodeDisconnect
|
DomainDisconnect,
|
||||||
|
DomainServerRemovedNode
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue