|
@@ -39,22 +39,25 @@ namespace InABox.Core
|
|
|
{
|
|
|
private List<IPollHandler> Handlers = new List<IPollHandler>();
|
|
|
|
|
|
- protected abstract void NotifyAll<TNotification>(TNotification notification);
|
|
|
- protected abstract void NotifySession<TNotification>(Guid session, TNotification notification);
|
|
|
+ protected abstract void NotifyAll<TNotification>(TNotification notification) where TNotification : BaseObject;
|
|
|
+ protected abstract void NotifySession<TNotification>(Guid session, TNotification notification) where TNotification : BaseObject;
|
|
|
protected abstract void NotifySession(Guid session, Type TNotification, object? notification);
|
|
|
protected abstract IEnumerable<Guid> GetUserSessions(Guid user);
|
|
|
protected abstract IEnumerable<Guid> GetSessions(Platform platform);
|
|
|
|
|
|
public void Push<TNotification>(TNotification notification)
|
|
|
+ where TNotification : BaseObject
|
|
|
{
|
|
|
NotifyAll(notification);
|
|
|
}
|
|
|
|
|
|
public void Push<TNotification>(Guid session, TNotification notification)
|
|
|
+ where TNotification : BaseObject
|
|
|
{
|
|
|
NotifySession(session, notification);
|
|
|
}
|
|
|
public void PushUser<TNotification>(Guid user, TNotification notification)
|
|
|
+ where TNotification : BaseObject
|
|
|
{
|
|
|
foreach (var session in GetUserSessions(user))
|
|
|
{
|
|
@@ -62,6 +65,7 @@ namespace InABox.Core
|
|
|
}
|
|
|
}
|
|
|
public void Push<TNotification>(Platform platform, TNotification notification)
|
|
|
+ where TNotification : BaseObject
|
|
|
{
|
|
|
foreach (var session in GetSessions(platform))
|
|
|
{
|
|
@@ -81,10 +85,12 @@ namespace InABox.Core
|
|
|
}
|
|
|
|
|
|
public void AddPollHandler<TNotification>(PollHandler<TNotification> handler)
|
|
|
+ where TNotification : BaseObject
|
|
|
{
|
|
|
Handlers.Add(handler);
|
|
|
}
|
|
|
public void AddPollHandler<TNotification>(PollHandler<TNotification>.PollEvent poll)
|
|
|
+ where TNotification : BaseObject
|
|
|
{
|
|
|
Handlers.Add(new PollHandler<TNotification>(poll));
|
|
|
}
|