25 lines
670 B
C#
25 lines
670 B
C#
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.SignalR;
|
|
using System;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Ordering.API.Infrastructure.Hubs
|
|
{
|
|
[Authorize]
|
|
public class NotificationsHub : Hub
|
|
{
|
|
|
|
public override async Task OnConnectedAsync()
|
|
{
|
|
await Groups.AddAsync(Context.ConnectionId, Context.User.Identity.Name);
|
|
await base.OnConnectedAsync();
|
|
}
|
|
|
|
public override async Task OnDisconnectedAsync(Exception ex)
|
|
{
|
|
await Groups.RemoveAsync(Context.ConnectionId, Context.User.Identity.Name);
|
|
await base.OnDisconnectedAsync(ex);
|
|
}
|
|
}
|
|
}
|