diff options
| author | JP Dillingham <jpdillingham@gmail.com> | 2021-09-19 12:36:16 -0500 |
|---|---|---|
| committer | JP Dillingham <jpdillingham@gmail.com> | 2021-09-19 12:36:16 -0500 |
| commit | f30ff919a6ca1b2c7ee195d0d5ecbd6594c6df2e (patch) | |
| tree | a8ab9cdd0f3ae472387a41a43a243dc256abf856 /src | |
| parent | 3272121e7c4b1c8bb1157c4953940c3018bd6d2d (diff) | |
| download | slskd-f30ff919a6ca1b2c7ee195d0d5ecbd6594c6df2e.tar.gz | |
broadcast state changes
Diffstat (limited to 'src')
| -rw-r--r-- | src/slskd/Application/Application.cs | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/slskd/Application/Application.cs b/src/slskd/Application/Application.cs index 1688c600..f167e673 100644 --- a/src/slskd/Application/Application.cs +++ b/src/slskd/Application/Application.cs @@ -25,6 +25,7 @@ namespace slskd using System.Reflection; using System.Threading; using System.Threading.Tasks; + using Microsoft.AspNetCore.SignalR; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Options; using Serilog; @@ -53,7 +54,8 @@ namespace slskd IRoomTracker roomTracker, IRoomService roomService, ISharedFileCache sharedFileCache, - IPushbulletService pushbulletService) + IPushbulletService pushbulletService, + IHubContext<Hub> hubContext) { OptionsAtStartup = optionsAtStartup; @@ -74,6 +76,7 @@ namespace slskd Pushbullet = pushbulletService; RoomService = roomService; + HubContext = hubContext; Client = soulseekClient; @@ -115,6 +118,7 @@ namespace slskd private DateTime SharesRefreshStarted { get; set; } private IManagedState<State> State { get; } private ITransferTracker TransferTracker { get; set; } + private IHubContext<Hub> HubContext { get; set; } /// <summary> /// Gets the version of the latest application release. @@ -719,7 +723,11 @@ namespace slskd } } - private void State_OnChange((State Previous, State Current) state) => Logger.Debug("State changed from {Previous} to {Current}", state.Previous.ToJson(), state.Current.ToJson()); + private void State_OnChange((State Previous, State Current) state) + { + Logger.Debug("State changed from {Previous} to {Current}", state.Previous.ToJson(), state.Current.ToJson()); + HubContext.BroadcastStateAsync(state.Current); + } /// <summary> /// Creates and returns a <see cref="UserInfo"/> object in response to a remote request. |
