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("WorkshopSlug",slug),
|
||||||
new("WorkshopId", account.WorkshopId.ToString()),
|
new("WorkshopId", account.WorkshopId.ToString()),
|
||||||
new("WorkshopName",account.WorkshopName??""),
|
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()
|
public override async Task OnConnectedAsync()
|
||||||
{
|
{
|
||||||
Console.WriteLine($"{Context.ConnectionId} connected");
|
var user = Context.User?.FindFirst("pm.userId")?.Value;
|
||||||
await Clients.All.SendAsync("ReceiveGreeting","A new user has connected to the Project Board Hub!");
|
|
||||||
|
if (user != null && user !="0")
|
||||||
|
{
|
||||||
|
await Groups.AddToGroupAsync(
|
||||||
|
Context.ConnectionId,
|
||||||
|
$"pm.user-{user}"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
await base.OnConnectedAsync();
|
await base.OnConnectedAsync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -24,7 +24,7 @@ public class SignalRBoardNotificationPublisher:IBoardNotificationPublisher
|
|||||||
NewStatus = newStatus,
|
NewStatus = newStatus,
|
||||||
SectionId = sectionId
|
SectionId = sectionId
|
||||||
};
|
};
|
||||||
_hubContext.Clients.User(userId.ToString()).SendAsync("ReceiveProjectStatusChanged",payload);
|
_hubContext.Clients.Group($"pm.user-{userId}").SendAsync("ReceiveProjectStatusChanged",payload);
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user