rdt-client/server/RdtClient.Service/Services/RemoteService.cs
Roger Far cd6002b5d6 Upgrade packages
Moved C# code to file scoped namespaces
Merged Startup.cs and Program.cs
2022-04-30 11:22:15 -06:00

32 lines
No EOL
901 B
C#

using Microsoft.AspNetCore.SignalR;
namespace RdtClient.Service.Services;
public class RemoteService
{
private readonly IHubContext<RdtHub> _hub;
private readonly Torrents _torrents;
public RemoteService(IHubContext<RdtHub> hub, Torrents torrents)
{
_hub = hub;
_torrents = torrents;
}
public async Task Update()
{
var torrents = await _torrents.Get();
// Prevent infinite recursion when serializing
foreach (var file in torrents.SelectMany(torrent => torrent.Downloads))
{
file.Torrent = null;
}
await _hub.Clients.All.SendCoreAsync("update",
new Object[]
{
torrents
});
}
}