Posts

Showing posts with the label signalr

Web push notification showing multiple times for multiple opened tabs

Web push notification showing multiple times for multiple opened tabs I've added web push notifications in my web app; in master layout (asp.net MVC) (using signalR). $(function () { // Declare a proxy to reference the hub. var notifications = $.connection.notificationHub; //debugger; // Create a function that the hub can call to broadcast messages. notifications.client.updateMessages = function () { getMeetingNotifications() }; // Start the connection. $.connection.hub.start().done(function () { // alert("connection started") getMeetingNotifications(); }).fail(function (e) { alert(e); }); }); If there are multiple tabs open for the same application. It pushes multiple notifications for the same activity. I resolved this by adding a tag field. function getMeetingNotifications() { $.ajax({ url: '@Url.Action("Index", "Home")', cache: false, type...

.Net Core Hosted Service Requires HttpContext

.Net Core Hosted Service Requires HttpContext EDIT Summary I have a background service, which requires a DBContext, my DbContext is dependent on the HttPContext, because it uses the UserClaims to filter the context. The HttpContext which is null when requesting the DbContext from BackgroundService, (this is by design because there is no WebRequest associated with a BackgroundService). How can I capture and moq the HTTPContext, so my user claims will carry over to the background service? I'm writing a hosted service to queue pushing messages from my Hubs in Signalr. My Background. public interface IBackgroundTaskQueue { void QueueBackgroundWorkItem(Func<IServiceProvider, CancellationToken, Task> workItem); Task<Func<IServiceProvider, CancellationToken, Task>> DequeueAsync(CancellationToken cancellationToken); } public class BackgroundTaskQueue : IBackgroundTaskQueue { private ConcurrentQueue<Func<IServiceProvider, CancellationToken, Task>>...