Fix threaded issues; add verify failed flag to avatar identity packet

Bump packet version
This commit is contained in:
Simon Walton 2019-04-23 09:26:17 -07:00
parent 7bca3c76bb
commit c03839e49f
6 changed files with 53 additions and 17 deletions

View file

@ -158,7 +158,7 @@ QByteArray MixerAvatar::canonicalJson(const QString fstFile) {
void MixerAvatar::processCertifyEvents() {
QMutexLocker certifyLocker(&_avatarCertifyLock);
if (_verifyState != kOwnerResponse && _verifyState != kChallengeResponse) {
if (_verifyState != kReceivedFST && _verifyState != kOwnerResponse && _verifyState != kChallengeResponse && _verifyState != kRequestingOwner) {
return;
}
@ -185,8 +185,8 @@ void MixerAvatar::processCertifyEvents() {
request["certificate_id"] = _certificateIdFromFST;
_verifyState = kRequestingOwner;
QNetworkReply* networkReply = networkAccessManager.put(networkRequest, QJsonDocument(request).toJson());
networkReply->setParent(this);
connect(networkReply, &QNetworkReply::finished, [this, networkReply]() {
//networkReply->setParent(this);
connect(networkReply, &QNetworkReply::readyRead, [this, networkReply]() {
QMutexLocker certifyLocker(&_avatarCertifyLock);
if (networkReply->error() == QNetworkReply::NoError) {
_dynamicMarketResponse = networkReply->readAll();
@ -205,6 +205,7 @@ void MixerAvatar::processCertifyEvents() {
_verifyState = kVerificationFailedPending;
qCDebug(avatars) << "Avatar" << getDisplayName() << "FAILED static certification";
}
break;
}
case kOwnerResponse:
@ -271,6 +272,15 @@ void MixerAvatar::processCertifyEvents() {
} else {
qCDebug(avatars) << "Dynamic verification SUCCEEDED for " << getDisplayName() << getSessionUUID();
}
break;
}
case kRequestingOwner:
{
certifyLocker.unlock();
QCoreApplication::processEvents();
break;
}
} // close switch

View file

@ -25,7 +25,7 @@ public:
void setNeedsHeroCheck(bool needsHeroCheck = true) { _needsHeroCheck = needsHeroCheck; }
void fetchAvatarFST();
bool isCertifyFailed() const { return _verifyState == kVerificationFailed || _verifyState == kVerificationFailedPending; }
virtual bool isCertifyFailed() const override { return _verifyState == kVerificationFailed || _verifyState == kVerificationFailedPending; }
void processCertifyEvents();
void handleChallengeResponse(ReceivedMessage * response);

View file

@ -1935,8 +1935,7 @@ void AvatarData::processAvatarIdentity(QDataStream& packetStream, bool& identity
>> identity.attachmentData
>> identity.displayName
>> identity.sessionDisplayName
>> identity.isReplicated
>> identity.lookAtSnappingEnabled
>> identity.identityFlags
;
if (incomingSequenceNumber > _identitySequenceNumber) {
@ -1951,8 +1950,22 @@ void AvatarData::processAvatarIdentity(QDataStream& packetStream, bool& identity
}
maybeUpdateSessionDisplayNameFromTransport(identity.sessionDisplayName);
if (identity.isReplicated != _isReplicated) {
_isReplicated = identity.isReplicated;
bool flagValue;
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;
}
@ -1961,11 +1974,6 @@ void AvatarData::processAvatarIdentity(QDataStream& packetStream, bool& identity
identityChanged = true;
}
if (identity.lookAtSnappingEnabled != _lookAtSnappingEnabled) {
setProperty("lookAtSnappingEnabled", identity.lookAtSnappingEnabled);
identityChanged = true;
}
#ifdef WANT_DEBUG
qCDebug(avatars) << __FUNCTION__
<< "identity.uuid:" << identity.uuid
@ -2084,17 +2092,27 @@ void AvatarData::prepareResetTraitInstances() {
QByteArray AvatarData::identityByteArray(bool setIsReplicated) const {
QByteArray identityData;
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
// 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()
<< (udt::SequenceNumber::Type) _identitySequenceNumber
<< _attachmentData
<< _displayName
<< getSessionDisplayNameForTransport() // depends on _sessionDisplayName
<< (_isReplicated || setIsReplicated)
<< _lookAtSnappingEnabled;
<< identityFlags;
return identityData;
}

View file

@ -329,6 +329,10 @@ namespace AvatarDataPacket {
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));
// AvatarIdentity packet:
enum class IdentityFlag: quint32 {none, isReplicated = 0x1, lookAtSnapping = 0x2, verificationFailed = 0x4};
Q_DECLARE_FLAGS(IdentityFlags, IdentityFlag)
struct SendStatus {
HasFlags itemFlags { 0 };
bool sendUUID { false };
@ -1132,6 +1136,7 @@ public:
QString sessionDisplayName;
bool isReplicated;
bool lookAtSnappingEnabled;
AvatarDataPacket::IdentityFlags identityFlags;
};
// identityChanged returns true if identity has changed, false otherwise.
@ -1163,6 +1168,7 @@ public:
_sessionDisplayName = sessionDisplayName;
markIdentityDataChanged();
}
virtual bool isCertifyFailed() const { return _verificationFailed; }
/**jsdoc
* Gets information about the models currently attached to your avatar.
@ -1639,6 +1645,7 @@ protected:
QString _displayName;
QString _sessionDisplayName { };
bool _lookAtSnappingEnabled { true };
bool _verificationFailed { false };
quint64 _errorLogExpiry; ///< time in future when to log an error

View file

@ -38,7 +38,7 @@ PacketVersion versionForPacketType(PacketType packetType) {
return static_cast<PacketVersion>(EntityQueryPacketVersion::ConicalFrustums);
case PacketType::AvatarIdentity:
case PacketType::AvatarData:
return static_cast<PacketVersion>(AvatarMixerPacketVersion::FBXJointOrderChange);
return static_cast<PacketVersion>(AvatarMixerPacketVersion::SendVerificationFailed);
case PacketType::BulkAvatarData:
case PacketType::KillAvatar:
return static_cast<PacketVersion>(AvatarMixerPacketVersion::FBXJointOrderChange);

View file

@ -331,7 +331,8 @@ enum class AvatarMixerPacketVersion : PacketVersion {
AvatarTraitsAck,
FasterAvatarEntities,
SendMaxTranslationDimension,
FBXJointOrderChange
FBXJointOrderChange,
SendVerificationFailed
};
enum class DomainConnectRequestVersion : PacketVersion {