mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-07-23 17:34:54 +02:00
Fix threaded issues; add verify failed flag to avatar identity packet
Bump packet version
This commit is contained in:
parent
7bca3c76bb
commit
c03839e49f
6 changed files with 53 additions and 17 deletions
|
@ -158,7 +158,7 @@ QByteArray MixerAvatar::canonicalJson(const QString fstFile) {
|
||||||
|
|
||||||
void MixerAvatar::processCertifyEvents() {
|
void MixerAvatar::processCertifyEvents() {
|
||||||
QMutexLocker certifyLocker(&_avatarCertifyLock);
|
QMutexLocker certifyLocker(&_avatarCertifyLock);
|
||||||
if (_verifyState != kOwnerResponse && _verifyState != kChallengeResponse) {
|
if (_verifyState != kReceivedFST && _verifyState != kOwnerResponse && _verifyState != kChallengeResponse && _verifyState != kRequestingOwner) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,8 +185,8 @@ void MixerAvatar::processCertifyEvents() {
|
||||||
request["certificate_id"] = _certificateIdFromFST;
|
request["certificate_id"] = _certificateIdFromFST;
|
||||||
_verifyState = kRequestingOwner;
|
_verifyState = kRequestingOwner;
|
||||||
QNetworkReply* networkReply = networkAccessManager.put(networkRequest, QJsonDocument(request).toJson());
|
QNetworkReply* networkReply = networkAccessManager.put(networkRequest, QJsonDocument(request).toJson());
|
||||||
networkReply->setParent(this);
|
//networkReply->setParent(this);
|
||||||
connect(networkReply, &QNetworkReply::finished, [this, networkReply]() {
|
connect(networkReply, &QNetworkReply::readyRead, [this, networkReply]() {
|
||||||
QMutexLocker certifyLocker(&_avatarCertifyLock);
|
QMutexLocker certifyLocker(&_avatarCertifyLock);
|
||||||
if (networkReply->error() == QNetworkReply::NoError) {
|
if (networkReply->error() == QNetworkReply::NoError) {
|
||||||
_dynamicMarketResponse = networkReply->readAll();
|
_dynamicMarketResponse = networkReply->readAll();
|
||||||
|
@ -205,6 +205,7 @@ void MixerAvatar::processCertifyEvents() {
|
||||||
_verifyState = kVerificationFailedPending;
|
_verifyState = kVerificationFailedPending;
|
||||||
qCDebug(avatars) << "Avatar" << getDisplayName() << "FAILED static certification";
|
qCDebug(avatars) << "Avatar" << getDisplayName() << "FAILED static certification";
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case kOwnerResponse:
|
case kOwnerResponse:
|
||||||
|
@ -271,6 +272,15 @@ void MixerAvatar::processCertifyEvents() {
|
||||||
} else {
|
} else {
|
||||||
qCDebug(avatars) << "Dynamic verification SUCCEEDED for " << getDisplayName() << getSessionUUID();
|
qCDebug(avatars) << "Dynamic verification SUCCEEDED for " << getDisplayName() << getSessionUUID();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case kRequestingOwner:
|
||||||
|
{
|
||||||
|
certifyLocker.unlock();
|
||||||
|
QCoreApplication::processEvents();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // close switch
|
} // close switch
|
||||||
|
|
|
@ -25,7 +25,7 @@ public:
|
||||||
void setNeedsHeroCheck(bool needsHeroCheck = true) { _needsHeroCheck = needsHeroCheck; }
|
void setNeedsHeroCheck(bool needsHeroCheck = true) { _needsHeroCheck = needsHeroCheck; }
|
||||||
|
|
||||||
void fetchAvatarFST();
|
void fetchAvatarFST();
|
||||||
bool isCertifyFailed() const { return _verifyState == kVerificationFailed || _verifyState == kVerificationFailedPending; }
|
virtual bool isCertifyFailed() const override { return _verifyState == kVerificationFailed || _verifyState == kVerificationFailedPending; }
|
||||||
void processCertifyEvents();
|
void processCertifyEvents();
|
||||||
void handleChallengeResponse(ReceivedMessage * response);
|
void handleChallengeResponse(ReceivedMessage * response);
|
||||||
|
|
||||||
|
|
|
@ -1935,8 +1935,7 @@ void AvatarData::processAvatarIdentity(QDataStream& packetStream, bool& identity
|
||||||
>> identity.attachmentData
|
>> identity.attachmentData
|
||||||
>> identity.displayName
|
>> identity.displayName
|
||||||
>> identity.sessionDisplayName
|
>> identity.sessionDisplayName
|
||||||
>> identity.isReplicated
|
>> identity.identityFlags
|
||||||
>> identity.lookAtSnappingEnabled
|
|
||||||
;
|
;
|
||||||
|
|
||||||
if (incomingSequenceNumber > _identitySequenceNumber) {
|
if (incomingSequenceNumber > _identitySequenceNumber) {
|
||||||
|
@ -1951,8 +1950,22 @@ void AvatarData::processAvatarIdentity(QDataStream& packetStream, bool& identity
|
||||||
}
|
}
|
||||||
maybeUpdateSessionDisplayNameFromTransport(identity.sessionDisplayName);
|
maybeUpdateSessionDisplayNameFromTransport(identity.sessionDisplayName);
|
||||||
|
|
||||||
if (identity.isReplicated != _isReplicated) {
|
bool flagValue;
|
||||||
_isReplicated = identity.isReplicated;
|
flagValue = identity.identityFlags.testFlag(AvatarDataPacket::IdentityFlag::isReplicated);
|
||||||
|
if ( flagValue != _isReplicated) {
|
||||||
|
_isReplicated = flagValue;
|
||||||
|
identityChanged = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
flagValue = identity.identityFlags.testFlag(AvatarDataPacket::IdentityFlag::lookAtSnapping);
|
||||||
|
if ( flagValue != _lookAtSnappingEnabled) {
|
||||||
|
setProperty("lookAtSnappingEnabled", flagValue);
|
||||||
|
identityChanged = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
flagValue = identity.identityFlags.testFlag(AvatarDataPacket::IdentityFlag::verificationFailed);
|
||||||
|
if (flagValue != _verificationFailed) {
|
||||||
|
_verificationFailed = flagValue;
|
||||||
identityChanged = true;
|
identityChanged = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1961,11 +1974,6 @@ void AvatarData::processAvatarIdentity(QDataStream& packetStream, bool& identity
|
||||||
identityChanged = true;
|
identityChanged = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (identity.lookAtSnappingEnabled != _lookAtSnappingEnabled) {
|
|
||||||
setProperty("lookAtSnappingEnabled", identity.lookAtSnappingEnabled);
|
|
||||||
identityChanged = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef WANT_DEBUG
|
#ifdef WANT_DEBUG
|
||||||
qCDebug(avatars) << __FUNCTION__
|
qCDebug(avatars) << __FUNCTION__
|
||||||
<< "identity.uuid:" << identity.uuid
|
<< "identity.uuid:" << identity.uuid
|
||||||
|
@ -2084,17 +2092,27 @@ void AvatarData::prepareResetTraitInstances() {
|
||||||
QByteArray AvatarData::identityByteArray(bool setIsReplicated) const {
|
QByteArray AvatarData::identityByteArray(bool setIsReplicated) const {
|
||||||
QByteArray identityData;
|
QByteArray identityData;
|
||||||
QDataStream identityStream(&identityData, QIODevice::Append);
|
QDataStream identityStream(&identityData, QIODevice::Append);
|
||||||
|
using namespace AvatarDataPacket;
|
||||||
|
|
||||||
// when mixers send identity packets to agents, they simply forward along the last incoming sequence number they received
|
// when mixers send identity packets to agents, they simply forward along the last incoming sequence number they received
|
||||||
// whereas agents send a fresh outgoing sequence number when identity data has changed
|
// whereas agents send a fresh outgoing sequence number when identity data has changed
|
||||||
|
IdentityFlags identityFlags = IdentityFlag::none;
|
||||||
|
if (_isReplicated || setIsReplicated) {
|
||||||
|
identityFlags.setFlag(IdentityFlag::isReplicated);
|
||||||
|
}
|
||||||
|
if (_lookAtSnappingEnabled) {
|
||||||
|
identityFlags.setFlag(IdentityFlag::lookAtSnapping);
|
||||||
|
}
|
||||||
|
if (isCertifyFailed()) {
|
||||||
|
identityFlags.setFlag(IdentityFlag::verificationFailed);
|
||||||
|
}
|
||||||
|
|
||||||
identityStream << getSessionUUID()
|
identityStream << getSessionUUID()
|
||||||
<< (udt::SequenceNumber::Type) _identitySequenceNumber
|
<< (udt::SequenceNumber::Type) _identitySequenceNumber
|
||||||
<< _attachmentData
|
<< _attachmentData
|
||||||
<< _displayName
|
<< _displayName
|
||||||
<< getSessionDisplayNameForTransport() // depends on _sessionDisplayName
|
<< getSessionDisplayNameForTransport() // depends on _sessionDisplayName
|
||||||
<< (_isReplicated || setIsReplicated)
|
<< identityFlags;
|
||||||
<< _lookAtSnappingEnabled;
|
|
||||||
|
|
||||||
return identityData;
|
return identityData;
|
||||||
}
|
}
|
||||||
|
|
|
@ -329,6 +329,10 @@ namespace AvatarDataPacket {
|
||||||
static const size_t MIN_BULK_PACKET_SIZE = NUM_BYTES_RFC4122_UUID + HEADER_SIZE;
|
static const size_t MIN_BULK_PACKET_SIZE = NUM_BYTES_RFC4122_UUID + HEADER_SIZE;
|
||||||
static const size_t FAUX_JOINTS_SIZE = 2 * (sizeof(SixByteQuat) + sizeof(SixByteTrans));
|
static const size_t FAUX_JOINTS_SIZE = 2 * (sizeof(SixByteQuat) + sizeof(SixByteTrans));
|
||||||
|
|
||||||
|
// AvatarIdentity packet:
|
||||||
|
enum class IdentityFlag: quint32 {none, isReplicated = 0x1, lookAtSnapping = 0x2, verificationFailed = 0x4};
|
||||||
|
Q_DECLARE_FLAGS(IdentityFlags, IdentityFlag)
|
||||||
|
|
||||||
struct SendStatus {
|
struct SendStatus {
|
||||||
HasFlags itemFlags { 0 };
|
HasFlags itemFlags { 0 };
|
||||||
bool sendUUID { false };
|
bool sendUUID { false };
|
||||||
|
@ -1132,6 +1136,7 @@ public:
|
||||||
QString sessionDisplayName;
|
QString sessionDisplayName;
|
||||||
bool isReplicated;
|
bool isReplicated;
|
||||||
bool lookAtSnappingEnabled;
|
bool lookAtSnappingEnabled;
|
||||||
|
AvatarDataPacket::IdentityFlags identityFlags;
|
||||||
};
|
};
|
||||||
|
|
||||||
// identityChanged returns true if identity has changed, false otherwise.
|
// identityChanged returns true if identity has changed, false otherwise.
|
||||||
|
@ -1163,6 +1168,7 @@ public:
|
||||||
_sessionDisplayName = sessionDisplayName;
|
_sessionDisplayName = sessionDisplayName;
|
||||||
markIdentityDataChanged();
|
markIdentityDataChanged();
|
||||||
}
|
}
|
||||||
|
virtual bool isCertifyFailed() const { return _verificationFailed; }
|
||||||
|
|
||||||
/**jsdoc
|
/**jsdoc
|
||||||
* Gets information about the models currently attached to your avatar.
|
* Gets information about the models currently attached to your avatar.
|
||||||
|
@ -1639,6 +1645,7 @@ protected:
|
||||||
QString _displayName;
|
QString _displayName;
|
||||||
QString _sessionDisplayName { };
|
QString _sessionDisplayName { };
|
||||||
bool _lookAtSnappingEnabled { true };
|
bool _lookAtSnappingEnabled { true };
|
||||||
|
bool _verificationFailed { false };
|
||||||
|
|
||||||
quint64 _errorLogExpiry; ///< time in future when to log an error
|
quint64 _errorLogExpiry; ///< time in future when to log an error
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ PacketVersion versionForPacketType(PacketType packetType) {
|
||||||
return static_cast<PacketVersion>(EntityQueryPacketVersion::ConicalFrustums);
|
return static_cast<PacketVersion>(EntityQueryPacketVersion::ConicalFrustums);
|
||||||
case PacketType::AvatarIdentity:
|
case PacketType::AvatarIdentity:
|
||||||
case PacketType::AvatarData:
|
case PacketType::AvatarData:
|
||||||
return static_cast<PacketVersion>(AvatarMixerPacketVersion::FBXJointOrderChange);
|
return static_cast<PacketVersion>(AvatarMixerPacketVersion::SendVerificationFailed);
|
||||||
case PacketType::BulkAvatarData:
|
case PacketType::BulkAvatarData:
|
||||||
case PacketType::KillAvatar:
|
case PacketType::KillAvatar:
|
||||||
return static_cast<PacketVersion>(AvatarMixerPacketVersion::FBXJointOrderChange);
|
return static_cast<PacketVersion>(AvatarMixerPacketVersion::FBXJointOrderChange);
|
||||||
|
|
|
@ -331,7 +331,8 @@ enum class AvatarMixerPacketVersion : PacketVersion {
|
||||||
AvatarTraitsAck,
|
AvatarTraitsAck,
|
||||||
FasterAvatarEntities,
|
FasterAvatarEntities,
|
||||||
SendMaxTranslationDimension,
|
SendMaxTranslationDimension,
|
||||||
FBXJointOrderChange
|
FBXJointOrderChange,
|
||||||
|
SendVerificationFailed
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class DomainConnectRequestVersion : PacketVersion {
|
enum class DomainConnectRequestVersion : PacketVersion {
|
||||||
|
|
Loading…
Reference in a new issue