mirror of
https://github.com/overte-org/overte.git
synced 2025-07-24 01:23:55 +02:00
Better handling of challenge timer
This commit is contained in:
parent
61668d3480
commit
9d0cd83ca4
2 changed files with 24 additions and 26 deletions
|
@ -27,10 +27,23 @@
|
||||||
#include "ClientTraitsHandler.h"
|
#include "ClientTraitsHandler.h"
|
||||||
#include "AvatarLogging.h"
|
#include "AvatarLogging.h"
|
||||||
|
|
||||||
MixerAvatar::~MixerAvatar() {
|
MixerAvatar::MixerAvatar() {
|
||||||
if (_challengeTimeout) {
|
static constexpr int CHALLENGE_TIMEOUT_MS = 10 * 1000; // 10 s
|
||||||
_challengeTimeout->deleteLater();
|
|
||||||
|
_challengeTimer.setSingleShot(true);
|
||||||
|
_challengeTimer.setInterval(CHALLENGE_TIMEOUT_MS);
|
||||||
|
|
||||||
|
_challengeTimer.callOnTimeout([this]() {
|
||||||
|
if (_verifyState == challengeClient) {
|
||||||
|
_pendingEvent = false;
|
||||||
|
_verifyState = verificationFailed;
|
||||||
|
_needsIdentityUpdate = true;
|
||||||
|
qCDebug(avatars) << "Dynamic verification TIMED-OUT for " << getDisplayName() << getSessionUUID();
|
||||||
|
} else {
|
||||||
|
qCDebug(avatars) << "Ignoring timeout of avatar challenge";
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* MixerAvatar::stateToName(VerifyState state) {
|
const char* MixerAvatar::stateToName(VerifyState state) {
|
||||||
|
@ -283,7 +296,6 @@ void MixerAvatar::processCertifyEvents() {
|
||||||
}
|
}
|
||||||
|
|
||||||
case requestingOwner:
|
case requestingOwner:
|
||||||
case challengeClient:
|
|
||||||
{ // Qt networking done on this thread:
|
{ // Qt networking done on this thread:
|
||||||
QCoreApplication::processEvents();
|
QCoreApplication::processEvents();
|
||||||
break;
|
break;
|
||||||
|
@ -314,29 +326,14 @@ void MixerAvatar::sendOwnerChallenge() {
|
||||||
_challengeNonceHash = nonceHash.result();
|
_challengeNonceHash = nonceHash.result();
|
||||||
_pendingEvent = false;
|
_pendingEvent = false;
|
||||||
|
|
||||||
static constexpr int CHALLENGE_TIMEOUT_MS = 10 * 1000; // 10 s
|
// QTimer::start is a set of overloaded functions.
|
||||||
if (_challengeTimeout) {
|
QMetaObject::invokeMethod(&_challengeTimer, static_cast<void(QTimer::*)()>(&QTimer::start));
|
||||||
_challengeTimeout->deleteLater();
|
|
||||||
}
|
|
||||||
_challengeTimeout = new QTimer();
|
|
||||||
_challengeTimeout->setInterval(CHALLENGE_TIMEOUT_MS);
|
|
||||||
_challengeTimeout->setSingleShot(true);
|
|
||||||
_challengeTimeout->connect(_challengeTimeout, &QTimer::timeout, this, [this]() {
|
|
||||||
if (_verifyState == challengeClient) {
|
|
||||||
_pendingEvent = false;
|
|
||||||
_verifyState = verificationFailed;
|
|
||||||
_needsIdentityUpdate = true;
|
|
||||||
qCDebug(avatars) << "Dynamic verification TIMED-OUT for " << getDisplayName() << getSessionUUID();
|
|
||||||
} else {
|
|
||||||
qCDebug(avatars) << "Ignoring timeout of avatar challenge";
|
|
||||||
}
|
|
||||||
});
|
|
||||||
_challengeTimeout->start();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MixerAvatar::handleChallengeResponse(ReceivedMessage& response) {
|
void MixerAvatar::handleChallengeResponse(ReceivedMessage& response) {
|
||||||
QByteArray avatarID;
|
QByteArray avatarID;
|
||||||
QMutexLocker certifyLocker(&_avatarCertifyLock);
|
QMutexLocker certifyLocker(&_avatarCertifyLock);
|
||||||
|
QMetaObject::invokeMethod(&_challengeTimer, &QTimer::stop);
|
||||||
if (_verifyState == challengeClient) {
|
if (_verifyState == challengeClient) {
|
||||||
QByteArray responseData = response.readAll();
|
QByteArray responseData = response.readAll();
|
||||||
if (responseData.length() < 8) {
|
if (responseData.length() < 8) {
|
||||||
|
|
|
@ -22,7 +22,8 @@ class ResourceRequest;
|
||||||
class MixerAvatar : public AvatarData {
|
class MixerAvatar : public AvatarData {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
~MixerAvatar();
|
MixerAvatar();
|
||||||
|
|
||||||
bool getNeedsHeroCheck() const { return _needsHeroCheck; }
|
bool getNeedsHeroCheck() const { return _needsHeroCheck; }
|
||||||
void setNeedsHeroCheck(bool needsHeroCheck = true) { _needsHeroCheck = needsHeroCheck; }
|
void setNeedsHeroCheck(bool needsHeroCheck = true) { _needsHeroCheck = needsHeroCheck; }
|
||||||
|
|
||||||
|
@ -57,7 +58,7 @@ private:
|
||||||
QString _dynamicMarketResponse;
|
QString _dynamicMarketResponse;
|
||||||
QString _ownerPublicKey;
|
QString _ownerPublicKey;
|
||||||
QByteArray _challengeNonceHash;
|
QByteArray _challengeNonceHash;
|
||||||
QTimer* _challengeTimeout { nullptr };
|
QTimer _challengeTimer;
|
||||||
bool _needsIdentityUpdate { false };
|
bool _needsIdentityUpdate { false };
|
||||||
|
|
||||||
bool generateFSTHash();
|
bool generateFSTHash();
|
||||||
|
|
Loading…
Reference in a new issue