Merge branch 'Feature/program-manager/signalR-notification' into Main
This commit is contained in:
@@ -199,7 +199,7 @@ public class AuthHelper : IAuthHelper
|
||||
new("WorkshopSlug",slug),
|
||||
new("WorkshopId", account.WorkshopId.ToString()),
|
||||
new("WorkshopName",account.WorkshopName??""),
|
||||
new("pm.userId", account.PmUserId?.ToString() ?? "0"),
|
||||
new("pm.userId", account.PmUserId.ToString()),
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -6,8 +6,16 @@ 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!");
|
||||
var user = Context.User?.FindFirst("pm.userId")?.Value;
|
||||
|
||||
if (user != null && user !="0")
|
||||
{
|
||||
await Groups.AddToGroupAsync(
|
||||
Context.ConnectionId,
|
||||
$"pm.user-{user}"
|
||||
);
|
||||
}
|
||||
|
||||
await base.OnConnectedAsync();
|
||||
}
|
||||
}
|
||||
@@ -24,7 +24,7 @@ public class SignalRBoardNotificationPublisher:IBoardNotificationPublisher
|
||||
NewStatus = newStatus,
|
||||
SectionId = sectionId
|
||||
};
|
||||
_hubContext.Clients.User(userId.ToString()).SendAsync("ReceiveProjectStatusChanged",payload);
|
||||
_hubContext.Clients.Group($"pm.user-{userId}").SendAsync("ReceiveProjectStatusChanged",payload);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user