mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 04:44:11 +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);
|
||||
}
|
||||
|
||||
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();
|
||||
_connectionToken = QUuid();
|
||||
|
||||
|
@ -60,6 +66,18 @@ void DomainHandler::clearConnectionInfo() {
|
|||
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() {
|
||||
_settingsObject = QJsonObject();
|
||||
_failedSettingsRequests = 0;
|
||||
|
@ -67,7 +85,7 @@ void DomainHandler::clearSettings() {
|
|||
|
||||
void DomainHandler::softReset() {
|
||||
qCDebug(networking) << "Resetting current domain connection information.";
|
||||
clearConnectionInfo();
|
||||
disconnect();
|
||||
clearSettings();
|
||||
}
|
||||
|
||||
|
|
|
@ -35,7 +35,6 @@ class DomainHandler : public QObject {
|
|||
public:
|
||||
DomainHandler(QObject* parent = 0);
|
||||
|
||||
void clearConnectionInfo();
|
||||
void clearSettings();
|
||||
|
||||
const QUuid& getUUID() const { return _uuid; }
|
||||
|
@ -113,6 +112,8 @@ signals:
|
|||
void settingsReceiveFail();
|
||||
|
||||
private:
|
||||
void disconnect();
|
||||
void sendDisconnectPacket();
|
||||
void hardReset();
|
||||
|
||||
QUuid _uuid;
|
||||
|
|
|
@ -19,7 +19,8 @@
|
|||
const QSet<PacketType> NON_VERIFIED_PACKETS = QSet<PacketType>()
|
||||
<< PacketType::NodeJsonStats << PacketType::EntityQuery
|
||||
<< PacketType::OctreeDataNack << PacketType::EntityEditNack
|
||||
<< PacketType::DomainListRequest << PacketType::StopNode;
|
||||
<< PacketType::DomainListRequest << PacketType::StopNode
|
||||
<< PacketType::DomainDisconnect;
|
||||
|
||||
const QSet<PacketType> NON_SOURCED_PACKETS = QSet<PacketType>()
|
||||
<< PacketType::StunResponse << PacketType::CreateAssignment << PacketType::RequestAssignment
|
||||
|
@ -30,7 +31,8 @@ const QSet<PacketType> NON_SOURCED_PACKETS = QSet<PacketType>()
|
|||
<< PacketType::DomainSettingsRequest << PacketType::DomainSettings
|
||||
<< PacketType::ICEServerPeerInformation << PacketType::ICEServerQuery << PacketType::ICEServerHeartbeat
|
||||
<< PacketType::ICEPing << PacketType::ICEPingReply
|
||||
<< PacketType::AssignmentClientStatus << PacketType::StopNode;
|
||||
<< PacketType::AssignmentClientStatus << PacketType::StopNode
|
||||
<< PacketType::DomainServerRemovedNode;
|
||||
|
||||
const QSet<PacketType> RELIABLE_PACKETS = QSet<PacketType>();
|
||||
|
||||
|
@ -48,8 +50,8 @@ PacketVersion versionForPacketType(PacketType packetType) {
|
|||
}
|
||||
|
||||
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
|
||||
// strongly typed enum for PacketType
|
||||
// seems odd that Qt couldn't figure out this cast itself, but this fixes a compile error after switch
|
||||
// to strongly typed enum for PacketType
|
||||
return qHash((quint8) key, seed);
|
||||
}
|
||||
|
||||
|
|
|
@ -86,7 +86,8 @@ public:
|
|||
AssetUploadReply,
|
||||
AssetGetInfo,
|
||||
AssetGetInfoReply,
|
||||
NodeDisconnect
|
||||
DomainDisconnect,
|
||||
DomainServerRemovedNode
|
||||
};
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue