mirror of
https://github.com/overte-org/overte.git
synced 2025-08-05 06:19:49 +02:00
repair broken node bandwidth stats
This commit is contained in:
parent
5989cad054
commit
9079f891e9
4 changed files with 17 additions and 8 deletions
|
@ -274,10 +274,14 @@ void LimitedNodeList::fillPacketHeader(const NLPacket& packet, const QUuid& conn
|
|||
|
||||
qint64 LimitedNodeList::sendUnreliablePacket(const NLPacket& packet, const Node& destinationNode) {
|
||||
Q_ASSERT(!packet.isPartOfMessage());
|
||||
|
||||
if (!destinationNode.getActiveSocket()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
emit dataSent(destinationNode.getType(), packet.getDataSize());
|
||||
destinationNode.recordBytesSent(packet.getDataSize());
|
||||
|
||||
return sendUnreliablePacket(packet, *destinationNode.getActiveSocket(), destinationNode.getConnectionSecret());
|
||||
}
|
||||
|
||||
|
@ -298,7 +302,10 @@ qint64 LimitedNodeList::sendPacket(std::unique_ptr<NLPacket> packet, const Node&
|
|||
if (!destinationNode.getActiveSocket()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
emit dataSent(destinationNode.getType(), packet->getDataSize());
|
||||
destinationNode.recordBytesSent(packet->getDataSize());
|
||||
|
||||
return sendPacket(std::move(packet), *destinationNode.getActiveSocket(), destinationNode.getConnectionSecret());
|
||||
}
|
||||
|
||||
|
|
|
@ -232,22 +232,22 @@ BandwidthRecorder& getBandwidthRecorder(const QUuid & uuid) {
|
|||
return *PEER_BANDWIDTH[uuid].data();
|
||||
}
|
||||
|
||||
void NetworkPeer::recordBytesSent(int count) {
|
||||
void NetworkPeer::recordBytesSent(int count) const {
|
||||
auto& bw = getBandwidthRecorder(_uuid);
|
||||
bw.updateOutboundData(0, count);
|
||||
}
|
||||
|
||||
void NetworkPeer::recordBytesReceived(int count) {
|
||||
void NetworkPeer::recordBytesReceived(int count) const {
|
||||
auto& bw = getBandwidthRecorder(_uuid);
|
||||
bw.updateInboundData(0, count);
|
||||
}
|
||||
|
||||
float NetworkPeer::getOutboundBandwidth() {
|
||||
float NetworkPeer::getOutboundBandwidth() const {
|
||||
auto& bw = getBandwidthRecorder(_uuid);
|
||||
return bw.getAverageOutputKilobitsPerSecond(0);
|
||||
}
|
||||
|
||||
float NetworkPeer::getInboundBandwidth() {
|
||||
float NetworkPeer::getInboundBandwidth() const {
|
||||
auto& bw = getBandwidthRecorder(_uuid);
|
||||
return bw.getAverageInputKilobitsPerSecond(0);
|
||||
}
|
||||
|
|
|
@ -70,11 +70,11 @@ public:
|
|||
void incrementConnectionAttempts() { ++_connectionAttempts; }
|
||||
void resetConnectionAttempts() { _connectionAttempts = 0; }
|
||||
|
||||
void recordBytesSent(int count);
|
||||
void recordBytesReceived(int count);
|
||||
void recordBytesSent(int count) const;
|
||||
void recordBytesReceived(int count) const;
|
||||
|
||||
float getOutboundBandwidth(); // in kbps
|
||||
float getInboundBandwidth(); // in kbps
|
||||
float getOutboundBandwidth() const; // in kbps
|
||||
float getInboundBandwidth() const; // in kbps
|
||||
|
||||
friend QDataStream& operator<<(QDataStream& out, const NetworkPeer& peer);
|
||||
friend QDataStream& operator>>(QDataStream& in, NetworkPeer& peer);
|
||||
|
|
|
@ -404,6 +404,8 @@ void PacketReceiver::handleVerifiedPacket(std::unique_ptr<udt::Packet> packet) {
|
|||
|
||||
if (matchingNode) {
|
||||
emit dataReceived(matchingNode->getType(), nlPacket->getDataSize());
|
||||
matchingNode->recordBytesReceived(nlPacket->getDataSize());
|
||||
|
||||
QMetaMethod metaMethod = listener.second;
|
||||
|
||||
static const QByteArray QSHAREDPOINTER_NODE_NORMALIZED = QMetaObject::normalizedType("QSharedPointer<Node>");
|
||||
|
|
Loading…
Reference in a new issue