Skip to content

Architrixs/NotificationLibrary

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Notification Library, Sends Notifications to Clients Using SignalR

Installation

Find the package on NuGet: https://www.nuget.org/packages/i2vNotificationLibrary

Find the package on Github: https://github.com/Architrixs/NotificationLibrary

This library requires a SignalR hub service to use IHubContext. Here's how to set it up:

Create a NotificationHub Extending Hub

public class NotificationHub : Hub
{
    // Hub implementation
}

Register Library Services

Register the library services, such as NotificationLibrary and NotificationSender, as singleton services in your application's dependency injection container:

services.AddSingleton<NotificationLibrary>();
services.AddSingleton<NotificationSender>();

Get Your Library Instance and Set the HubContext

In your NotificationHub constructor, set up the IHubContext and initialize your library:

public NotificationHub(IHubContext<NotificationHub> hub, NotificationLibrary notificationLibrary)
{
    notificationHub = hub;
    notificationLibrary.SetHubContext(notificationHub);
    
    // Register your entities
    notificationLibrary.RegisterEntity<VideoSource>("VideoSource");
    notificationLibrary.RegisterEntity<AnalyticServer>("AnalyticServer");
    notificationLibrary.RegisterEntity<User>("User");
}

Basic Usage

You can inject the NotificationLibrary in a controller and call its Method like so:

_notificationLibrary.SendNotificationToAll("crudNotification", OperationType.Update, videoSource, message);

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages