feat: implement SignalR notifications for project status changes
This commit is contained in:
13
ServiceHost/Hubs/ProgramManager/ProjectBoardHub.cs
Normal file
13
ServiceHost/Hubs/ProgramManager/ProjectBoardHub.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
|
||||
namespace ServiceHost.Hubs.ProgramManager;
|
||||
|
||||
public class ProjectBoardHub:Hub
|
||||
{
|
||||
public override async Task OnConnectedAsync()
|
||||
{
|
||||
Console.WriteLine($"{Context.ConnectionId} connected");
|
||||
await Clients.All.SendAsync("ReceiveGreeting","A new user has connected to the Project Board Hub!");
|
||||
await base.OnConnectedAsync();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
using GozareshgirProgramManager.Application.Interfaces;
|
||||
using GozareshgirProgramManager.Domain.ProjectAgg.Enums;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
using ServiceHost.Hubs.ProgramManager;
|
||||
|
||||
namespace ServiceHost.Notifications.ProgramManager;
|
||||
|
||||
public class SignalRBoardNotificationPublisher:IBoardNotificationPublisher
|
||||
{
|
||||
private readonly IHubContext<ProjectBoardHub> _hubContext;
|
||||
|
||||
public SignalRBoardNotificationPublisher(IHubContext<ProjectBoardHub> hubContext)
|
||||
{
|
||||
_hubContext = hubContext;
|
||||
}
|
||||
|
||||
public Task SendProjectStatusChanged(long userId, TaskSectionStatus oldStatus,
|
||||
TaskSectionStatus newStatus, Guid sectionId)
|
||||
{
|
||||
var payload = new
|
||||
{
|
||||
UserId = userId,
|
||||
OldStatus = oldStatus,
|
||||
NewStatus = newStatus,
|
||||
SectionId = sectionId
|
||||
};
|
||||
_hubContext.Clients.User(userId.ToString()).SendAsync("ReceiveProjectStatusChanged",payload);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
@@ -31,6 +31,7 @@ using GozareshgirProgramManager.Application.Modules.Users.Commands.CreateUser;
|
||||
using GozareshgirProgramManager.Infrastructure;
|
||||
using GozareshgirProgramManager.Infrastructure.Persistence.Seed;
|
||||
using Microsoft.OpenApi;
|
||||
using ServiceHost.Hubs.ProgramManager;
|
||||
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
@@ -451,6 +452,7 @@ app.MapHub<HolidayApiHub>("/trackingHolidayHub");
|
||||
app.MapHub<CheckoutHub>("/trackingCheckoutHub");
|
||||
// app.MapHub<FaceEmbeddingHub>("/trackingFaceEmbeddingHub");
|
||||
app.MapHub<SendSmsHub>("/trackingSendSmsHub");
|
||||
app.MapHub<ProjectBoardHub>("/pm/board");
|
||||
app.MapRazorPages();
|
||||
app.MapControllers();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user