DD.WellWorkover.Cloud/AsbCloudWebApi/SignalR/NotificationHub.cs

35 lines
936 B
C#

using System.Threading;
using System.Threading.Tasks;
using AsbCloudApp.Data;
using AsbCloudApp.Services.Notifications;
using AsbCloudWebApi.SignalR.ConnectionManager;
using Microsoft.AspNetCore.Authorization;
namespace AsbCloudWebApi.SignalR;
[Authorize]
public class NotificationHub : BaseHub
{
private readonly IConnectionManager connectionManager;
private readonly INotificationService notificationService;
public NotificationHub(IConnectionManager connectionManager,
INotificationService notificationService)
{
this.connectionManager = connectionManager;
this.notificationService = notificationService;
}
public async Task OnConnected(int idUser)
{
string connectionId = Context.ConnectionId;
connectionManager.AddConnection(idUser, connectionId);
await notificationService.ResendNotificationAsync(idUser,
NotificationTransport.SignalR,
CancellationToken.None);
await base.OnConnectedAsync();
}
}