An open API service indexing awesome lists of open source software.

https://github.com/architrixs/notificationlibrary


https://github.com/architrixs/notificationlibrary

Last synced: 10 months ago
JSON representation

Awesome Lists containing this project

README

          

## 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
```C#
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:
```C#
services.AddSingleton();
services.AddSingleton();
```
### Get Your Library Instance and Set the HubContext
In your NotificationHub constructor, set up the IHubContext and initialize your library:

```C#
public NotificationHub(IHubContext hub, NotificationLibrary notificationLibrary)
{
notificationHub = hub;
notificationLibrary.SetHubContext(notificationHub);

// Register your entities
notificationLibrary.RegisterEntity("VideoSource");
notificationLibrary.RegisterEntity("AnalyticServer");
notificationLibrary.RegisterEntity("User");
}
```
### Basic Usage
You can inject the NotificationLibrary in a controller and call its Method like so:
```C#
_notificationLibrary.SendNotificationToAll("crudNotification", OperationType.Update, videoSource, message);
```