12345678910111213141516171819202122232425262728293031 |
- using System;
- using System.Collections.Generic;
- using System.Text;
- namespace InABox.Core
- {
- /// <summary>
- /// Client-side push manager.
- /// </summary>
- public class PushHandlers
- {
- private Dictionary<Type, IPushHandler> Handlers = new Dictionary<Type, IPushHandler>();
- public void AddHandler<TPush>(PushHandler<TPush> handler)
- {
- Handlers[typeof(TPush)] = handler;
- }
- public void AddHandler<TPush>(PushHandler<TPush>.ReceiveEvent receive)
- {
- Handlers[typeof(TPush)] = new PushHandler<TPush>(receive);
- }
- public void Push(Type type, object? push)
- {
- if (Handlers.TryGetValue(type, out var handler))
- {
- handler.Receive(push);
- }
- }
- }
- }
|