From 86bab11ddbd008f236006ee49bde7de40106675c Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sun, 14 Jun 2026 14:33:24 -0500 Subject: stub the MetricsHub --- src/slskd/Telemetry/API/MetricsHub.cs | 61 +++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 src/slskd/Telemetry/API/MetricsHub.cs (limited to 'src') diff --git a/src/slskd/Telemetry/API/MetricsHub.cs b/src/slskd/Telemetry/API/MetricsHub.cs new file mode 100644 index 00000000..ff4a6eeb --- /dev/null +++ b/src/slskd/Telemetry/API/MetricsHub.cs @@ -0,0 +1,61 @@ +// +// ▄▄▄▄ ▄▄▄▄ ▄▄▄▄ +// ▄▄▄▄▄▄█ █▄▄▄▄▄█ █▄▄▄▄▄█ █ +// █__ --█ █__ --█ ◄█ - █ +// █▄▄▄▄▄█▄▄█▄▄▄▄▄█▄▄█▄▄█▄▄▄▄▄█ +// ┍━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ━━━━ ━ ━┉ ┉ ┉ +// │ Copyright (c) JP Dillingham. +// │ +// │ This program is free software: you can redistribute it and/or modify +// │ it under the terms of the GNU Affero General Public License as published +// │ by the Free Software Foundation, version 3. +// │ +// │ This program is distributed in the hope that it will be useful, +// │ but WITHOUT ANY WARRANTY; without even the implied warranty of +// │ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// │ GNU Affero General Public License for more details. +// │ +// │ You should have received a copy of the GNU Affero General Public License +// │ along with this program. If not, see https://www.gnu.org/licenses/. +// │ +// │ This program is distributed with Additional Terms pursuant to Section 7 +// │ of the AGPLv3. See the LICENSE file in the root directory of this +// │ project for the complete terms and conditions. +// │ +// │ https://slskd.org +// │ +// ├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌ ╌ ╌╌╌╌ ╌ +// │ SPDX-FileCopyrightText: JP Dillingham +// │ SPDX-License-Identifier: AGPL-3.0-only +// ╰───────────────────────────────────────────╶──── ─ ─── ─ ── ──┈ ┈ +// + +using System.Threading.Tasks; +using Microsoft.AspNetCore.SignalR; + +namespace slskd.Telemetry; + +public static class MetricsHubMethods +{ + public static readonly string TRANSFERS = nameof(TRANSFERS); +} + +public static class ApplicationHubExtensions +{ + public static Task BroadcastTransferMetrics(this IHubContext hub) + { + return hub.Clients.All.SendAsync(MetricsHubMethods.TRANSFERS, new { }); + } +} + +public class MetricsHub : Hub +{ + public MetricsHub() + { + } + + public override async Task OnConnectedAsync() + { + await Clients.Caller.SendAsync(MetricsHubMethods.TRANSFERS, new { }); + } +} \ No newline at end of file -- cgit v1.2.3