1
0
mirror of https://github.com/bitwarden/server synced 2026-01-08 03:23:20 +00:00

stub out signalr sync hub

This commit is contained in:
Kyle Spearrin
2018-08-02 12:14:33 -04:00
parent 14956f6383
commit 8b53ab2945
13 changed files with 460 additions and 84 deletions

33
src/Hub/SyncHub.cs Normal file
View File

@@ -0,0 +1,33 @@
using System;
using System.Threading.Tasks;
using Bit.Core;
using Microsoft.AspNetCore.Authorization;
namespace Bit.Hub
{
[Authorize("Application")]
public class SyncHub : Microsoft.AspNetCore.SignalR.Hub
{
public override async Task OnConnectedAsync()
{
var currentContext = new CurrentContext();
currentContext.Build(Context.User);
foreach(var org in currentContext.Organizations)
{
await Groups.AddToGroupAsync(Context.ConnectionId, $"Organization_{org.Id}");
}
await base.OnConnectedAsync();
}
public override async Task OnDisconnectedAsync(Exception exception)
{
var currentContext = new CurrentContext();
currentContext.Build(Context.User);
foreach(var org in currentContext.Organizations)
{
await Groups.RemoveFromGroupAsync(Context.ConnectionId, $"Organization_{org.Id}");
}
await base.OnDisconnectedAsync(exception);
}
}
}