https://github.com/architrixs/notificationlibrary
https://github.com/architrixs/notificationlibrary
Last synced: 10 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/architrixs/notificationlibrary
- Owner: Architrixs
- Created: 2023-10-31T06:52:11.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-11-01T11:03:11.000Z (over 2 years ago)
- Last Synced: 2025-01-06T17:26:36.018Z (over 1 year ago)
- Language: C#
- Size: 8.79 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
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);
```