From 98d097517b70cc5af6354869f1201ecd59f86079 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Tue, 1 Apr 2025 16:45:58 +0200 Subject: [PATCH] Introduce Endpoint#messages_received_per_type --- lib/remote/endpoint.cpp | 13 +++++++++++++ lib/remote/endpoint.hpp | 2 ++ lib/remote/endpoint.ti | 4 ++++ 3 files changed, 19 insertions(+) diff --git a/lib/remote/endpoint.cpp b/lib/remote/endpoint.cpp index 48621432c..db908e558 100644 --- a/lib/remote/endpoint.cpp +++ b/lib/remote/endpoint.cpp @@ -149,3 +149,16 @@ double Endpoint::GetBytesReceivedPerSecond() const { return m_BytesReceived.CalculateRate(Utility::GetTime(), 60); } + +Dictionary::Ptr Endpoint::GetMessagesReceivedPerType() const +{ + DictionaryData result; + + for (auto& [afunc, cnt] : m_MessageCounters) { + if (auto v (cnt.load(std::memory_order_relaxed)); v) { + result.emplace_back(afunc->GetName(), v); + } + } + + return new Dictionary(std::move(result)); +} diff --git a/lib/remote/endpoint.hpp b/lib/remote/endpoint.hpp index 2ccfc053f..09ad8a4fd 100644 --- a/lib/remote/endpoint.hpp +++ b/lib/remote/endpoint.hpp @@ -56,6 +56,8 @@ public: double GetBytesSentPerSecond() const override; double GetBytesReceivedPerSecond() const override; + Dictionary::Ptr GetMessagesReceivedPerType() const override; + protected: void OnAllConfigLoaded() override; diff --git a/lib/remote/endpoint.ti b/lib/remote/endpoint.ti index 78551ecf0..2fa874b5e 100644 --- a/lib/remote/endpoint.ti +++ b/lib/remote/endpoint.ti @@ -54,6 +54,10 @@ class Endpoint : ConfigObject [no_user_modify, no_storage] double bytes_received_per_second { get; }; + + [no_user_modify, no_storage] Dictionary::Ptr messages_received_per_type { + get; + }; }; }