using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace InABox.Core
{
public interface INotificationHandler
{
///
/// Receives a new notification from the server, called when a notification is pushed.
///
/// The notification object
void Receive(object? o);
}
public class NotificationHandler : INotificationHandler
{
public delegate void ReceiveEvent(TNotification notification);
public event ReceiveEvent? OnReceive;
public NotificationHandler() { }
public NotificationHandler(ReceiveEvent receive)
{
OnReceive += receive;
}
public void Receive(object? notification) => Receive((TNotification)notification);
///
/// Receives a new notification from the server, called when a notification is pushed.
///
/// The notification received
public void Receive(TNotification notification)
{
OnReceive?.Invoke(notification);
}
}
}