1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-18 16:11:28 -05:00

connection counter

This commit is contained in:
Kyle Spearrin
2018-08-23 15:48:40 -04:00
parent 43e5f300a7
commit d458d77511
5 changed files with 115 additions and 13 deletions

View File

@ -8,6 +8,13 @@ namespace Bit.Notifications
[Authorize("Application")]
public class NotificationsHub : Microsoft.AspNetCore.SignalR.Hub
{
private readonly ConnectionCounter _connectionCounter;
public NotificationsHub(ConnectionCounter connectionCounter)
{
_connectionCounter = connectionCounter;
}
public override async Task OnConnectedAsync()
{
var currentContext = new CurrentContext();
@ -16,6 +23,7 @@ namespace Bit.Notifications
{
await Groups.AddToGroupAsync(Context.ConnectionId, $"Organization_{org.Id}");
}
_connectionCounter.Increment();
await base.OnConnectedAsync();
}
@ -27,6 +35,7 @@ namespace Bit.Notifications
{
await Groups.RemoveFromGroupAsync(Context.ConnectionId, $"Organization_{org.Id}");
}
_connectionCounter.Decrement();
await base.OnDisconnectedAsync(exception);
}
}