Showing the changes to assignment-client/src/scripts/EntityScriptServer.cpp (1 of 1 file). Show all
Unified · Split
| @@ -557,8 +557,50 @@ void EntityScriptServer::checkAndCallPreload(const EntityItemID& entityID, bool · 556 unmodified lines | ||
| 557 | 557 | |
| 558 | 558 | void EntityScriptServer::sendStatsPacket() { |
| 559 | 559 | QJsonObject statsObject; |
| 560 | − // Add ESS-specific ... | |
| 561 | − ThreadedAssignment::addPacketStatsAndSendStatsPacket(statsObject); | |
| 560 | + | |
| 561 | + QJsonObject octreeStats; | |
| 562 | + octreeStats["elementCount"] = (double)OctreeElement::getNodeCount(); | |
| 563 | + octreeStats["internalElementCount"] = (double)OctreeElement::getInternalNodeCount(); | |
| 564 | + octreeStats["leafElementCount"] = (double)OctreeElement::getLeafNodeCount(); | |
| 565 | + statsObject["octree_stats"] = octreeStats; | |
| 566 | + | |
| 567 | + QJsonObject scriptEngineStats; | |
| 568 | + int numberRunningScripts = 0; | |
| 569 | + const auto scriptEngine = _entitiesScriptEngine; | |
| 570 | + if (scriptEngine) { | |
| 571 | + numberRunningScripts = scriptEngine->getNumRunningEntityScripts(); | |
| 572 | + } | |
| 573 | + scriptEngineStats["number_running_scripts"] = numberRunningScripts; | |
| 574 | + statsObject["script_engine_stats"] = scriptEngineStats; | |
| 575 | + | |
| 576 | + | |
| 577 | + auto nodeList = DependencyManager::get<NodeList>(); | |
| 578 | + QJsonObject nodesObject; | |
| 579 | + nodeList->eachNode([&](const SharedNodePointer& node) { | |
| 580 | + QJsonObject clientStats; | |
| 581 | + const QString uuidString(uuidStringWithoutCurlyBraces(node->getUUID())); | |
| 582 | + clientStats["node_type"] = NodeType::getNodeTypeName(node->getType()); | |
| 583 | + auto& nodeStats = node->getConnectionStats(); | |
| 584 | + | |
| 585 | + static const QString NODE_OUTBOUND_KBPS_STAT_KEY("outbound_kbit/s"); | |
| 586 | + static const QString NODE_INBOUND_KBPS_STAT_KEY("inbound_kbit/s"); | |
| 587 | + | |
| 588 | + // add the key to ask the domain-server for a username replacement, if it has it | |
| 589 | + clientStats[USERNAME_UUID_REPLACEMENT_STATS_KEY] = uuidString; | |
| 590 | + | |
| 591 | + clientStats[NODE_OUTBOUND_KBPS_STAT_KEY] = node->getOutboundKbps(); | |
| 592 | + clientStats[NODE_INBOUND_KBPS_STAT_KEY] = node->getInboundKbps(); | |
| 593 | + | |
| 594 | + using namespace std::chrono; | |
| 595 | + const float statsPeriod = duration<float, seconds::period>(nodeStats.endTime - nodeStats.startTime).count(); | |
| 596 | + clientStats["unreliable_packet/s"] = (nodeStats.sentUnreliablePackets + nodeStats.receivedUnreliablePackets) / statsPeriod; | |
| 597 | + clientStats["reliable_packet/s"] = (nodeStats.sentPackets + nodeStats.receivedPackets) / statsPeriod; | |
| 598 | + | |
| 599 | + nodesObject[uuidString] = clientStats; | |
| 600 | + }); | |
| 601 | + | |
| 602 | + statsObject["nodes"] = nodesObject; | |
| 603 | + addPacketStatsAndSendStatsPacket(statsObject); | |
| 562 | 604 | } |
| 563 | 605 | |
| 564 | 606 | void EntityScriptServer::handleOctreePacket(QSharedPointer<ReceivedMessage> message, SharedNodePointer senderNode) { |