mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 11:45:36 +02:00
fix string JSON unmarshal, add basic avatar values
This commit is contained in:
parent
73da4828b1
commit
2c0604afd1
5 changed files with 30 additions and 6 deletions
|
@ -337,9 +337,25 @@ void AvatarMixer::sendStatsPacket() {
|
|||
|
||||
statsObject["trailing_sleep_percentage"] = _trailingSleepRatio * 100;
|
||||
statsObject["performance_throttling_ratio"] = _performanceThrottlingRatio;
|
||||
|
||||
QJsonObject avatarsObject;
|
||||
|
||||
auto nodeList = DependencyManager::get<NodeList>();
|
||||
// add stats for each listerner
|
||||
nodeList->eachNode([&](const SharedNodePointer& node) {
|
||||
QJsonObject avatarStats;
|
||||
avatarStats["bytes_per_second"] = node->getOutboundBandwidth();
|
||||
AvatarMixerClientData* clientData = static_cast<AvatarMixerClientData*>(node->getLinkedData());
|
||||
if (clientData) {
|
||||
clientData->loadJSONStats(avatarStats);
|
||||
}
|
||||
|
||||
avatarsObject[uuidStringWithoutCurlyBraces(node->getUUID())] = avatarStats;
|
||||
});
|
||||
|
||||
statsObject["avatars"] = avatarsObject;
|
||||
ThreadedAssignment::addPacketStatsAndSendStatsPacket(statsObject);
|
||||
|
||||
|
||||
_sumListeners = 0;
|
||||
_sumBillboardPackets = 0;
|
||||
_sumIdentityPackets = 0;
|
||||
|
|
|
@ -33,3 +33,8 @@ bool AvatarMixerClientData::checkAndSetHasReceivedFirstPackets() {
|
|||
_hasReceivedFirstPackets = true;
|
||||
return oldValue;
|
||||
}
|
||||
|
||||
void AvatarMixerClientData::loadJSONStats(QJsonObject& jsonObject) const {
|
||||
jsonObject["display_name"] = _avatar.getDisplayName();
|
||||
jsonObject["full_rate_distance"] = _fullRateDistance;
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
#include <cfloat>
|
||||
|
||||
#include <QtCore/QJsonObject>
|
||||
#include <QtCore/QUrl>
|
||||
|
||||
#include <AvatarData.h>
|
||||
|
@ -35,7 +36,9 @@ public:
|
|||
quint64 getIdentityChangeTimestamp() const { return _identityChangeTimestamp; }
|
||||
void setIdentityChangeTimestamp(quint64 identityChangeTimestamp) { _identityChangeTimestamp = identityChangeTimestamp; }
|
||||
|
||||
float getFullRateDistance() const { return _fullRateDistance; }
|
||||
float getFullRateDistance() const { return _fullRateDistance; }
|
||||
|
||||
void loadJSONStats(QJsonObject& jsonObject) const;
|
||||
private:
|
||||
AvatarData _avatar;
|
||||
bool _hasReceivedFirstPackets;
|
||||
|
|
|
@ -121,10 +121,10 @@ QVariant JSONBreakableMarshal::fromString(const QString& marshalValue) {
|
|||
} else {
|
||||
// we need to figure out if this is a string
|
||||
// use a regex to look for surrounding quotes first
|
||||
const QString JSON_STRING_REGEX = "\\A\"([\\w\\W]*)\"\\z";
|
||||
const QString JSON_STRING_REGEX = "^\"([\\s\\S]*)\"$";
|
||||
QRegExp stringRegex(JSON_STRING_REGEX);
|
||||
|
||||
if (stringRegex.indexIn(marshalValue)) {
|
||||
|
||||
if (stringRegex.indexIn(marshalValue) != -1) {
|
||||
// set the result to the string value
|
||||
result = stringRegex.cap(1);
|
||||
} else {
|
||||
|
|
|
@ -73,7 +73,7 @@ qint64 NodeList::sendStats(const QJsonObject& statsObject, const HifiSockAddr& d
|
|||
|
||||
// get a QStringList using JSONBreakableMarshal
|
||||
QStringList statsStringList = JSONBreakableMarshal::toStringList(statsObject, "");
|
||||
|
||||
|
||||
int numBytesWritten = numBytesForPacketHeader;
|
||||
|
||||
// enumerate the resulting strings - pack them and send off packets once we hit MTU size
|
||||
|
|
Loading…
Reference in a new issue