rdt-client/server/RdtClient.Service/Services/RdtHub.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

23 lines
No EOL
641 B
C#

using System.Collections.Concurrent;
using Microsoft.AspNetCore.SignalR;
namespace RdtClient.Service.Services;
public class RdtHub : Hub
{
private static readonly ConcurrentDictionary<String, String> Users = new();
public static Boolean HasConnections => Users.Any();
public override async Task OnConnectedAsync()
{
Users.TryAdd(Context.ConnectionId, Context.ConnectionId);
await base.OnConnectedAsync();
}
public override async Task OnDisconnectedAsync(Exception exception)
{
Users.TryRemove(Context.ConnectionId, out _);
await base.OnDisconnectedAsync(exception);
}
}