aboutsummaryrefslogtreecommitdiffstats
path: root/src/slskd/Application.cs
diff options
context:
space:
mode:
authorJP Dillingham <jp@dillingham.me>2026-02-01 14:11:40 -0600
committerJP Dillingham <jp@dillingham.me>2026-02-01 14:11:40 -0600
commita3e880e813d97e917ba2f41b756e2430efd7d60e (patch)
treef4a6c62986cb4d1a5a6be7943f22791ada7d2940 /src/slskd/Application.cs
parent2b3e6f30420128940c6c626b78028386e6c5a54b (diff)
downloadslskd-a3e880e813d97e917ba2f41b756e2430efd7d60e.tar.gz
add events for client connect and disconnect
Diffstat (limited to 'src/slskd/Application.cs')
-rw-r--r--src/slskd/Application.cs15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/slskd/Application.cs b/src/slskd/Application.cs
index bed8aab2..93db9073 100644
--- a/src/slskd/Application.cs
+++ b/src/slskd/Application.cs
@@ -40,6 +40,7 @@ namespace slskd
using Serilog.Events;
using slskd.Configuration;
using slskd.Core.API;
+ using slskd.Events;
using slskd.Files;
using slskd.Integrations.Pushbullet;
using slskd.Messaging;
@@ -105,7 +106,8 @@ namespace slskd
IPushbulletService pushbulletService,
IRelayService relayService,
IHubContext<ApplicationHub> applicationHub,
- IHubContext<LogsHub> logHub)
+ IHubContext<LogsHub> logHub,
+ EventBus eventBus)
{
Console.CancelKeyPress += (_, args) =>
{
@@ -130,6 +132,8 @@ namespace slskd
OptionsMonitor = optionsMonitor;
OptionsMonitor.OnChange(async options => await OptionsMonitor_OnChange(options));
+ EventBus = eventBus;
+
IncomingSearchRequestSemaphore = new SemaphoreSlim(
initialCount: OptionsAtStartup.Throttling.Search.Incoming.Concurrency,
maxCount: OptionsAtStartup.Throttling.Search.Incoming.Concurrency);
@@ -240,6 +244,7 @@ namespace slskd
private ITransferService Transfers { get; init; }
private IHubContext<ApplicationHub> ApplicationHub { get; set; }
private IHubContext<LogsHub> LogHub { get; set; }
+ private EventBus EventBus { get; }
private IUserService Users { get; set; }
private IShareService Shares { get; set; }
private ISearchService Search { get; set; }
@@ -900,6 +905,8 @@ namespace slskd
{
ConnectionWatchdog.Stop();
Log.Information("Connected to the Soulseek server");
+
+ EventBus.Raise(new SoulseekClientConnectedEvent());
}
private void Client_DiagnosticGenerated(object sender, DiagnosticEventArgs args)
@@ -960,6 +967,12 @@ namespace slskd
Log.Error("Disconnected from the Soulseek server: {Message}", args.Exception?.Message ?? args.Message);
ConnectionWatchdog.Start();
}
+
+ EventBus.Raise(new SoulseekClientDisconnectedEvent()
+ {
+ Message = args.Message,
+ Exception = args.Exception,
+ });
}
private async Task RefreshUserStatistics(bool force = false)