-
Notifications
You must be signed in to change notification settings - Fork 37
Handle events server side
SignalR.EventAggregatorProxy does not depend on a specific service bus or event aggregator. So you need to create a proxy for your implementation so that the library can hook into the events.
Implement SignalR.EventAggregatorProxy.EventAggregation.IEventAggregator
namespace SignalR.EventAggregatorProxy.EventAggregation
{
public interface IEventAggregator
{
void Subscribe(Func<object, Task> handler);
}
}
When a message comes in that you want to forward just execute the Action delegate (Check it for null because maybe its not hooked up yet)
The library uses the Dot Net Core dependency injection to get the IEventAggregator
so make sure you register this.
services
.AddSignalREventAggregator()
.AddSingleton<IEventAggregator, EventAggregator>()
SignalR.EventAggregatorProxy does not depend on a specific service bus or event aggregator. So you need to create a proxy for your implementation so that the library can hook into the events.
Implement SignalR.EventAggregatorProxy.EventAggregation.IEventAggregator
namespace SignalR.EventAggregatorProxy.EventAggregation
{
public interface IEventAggregator
{
void Subscribe(Action<object> handler);
}
}
When a message comes in that you want to forward just execute the Action delegate (Check it for null because maybe its not hooked up yet)
The library uses the SignalR Dependency resolver to get the IEventAggregator so make sure you register this. Either with a IoC of your choice or the built in SignalR Dependency resolver
var proxy = new Lazy<IEventAggregator>(() => new MyEventAggregatorProxy());
GlobalHost.DependencyResolver.Register(typeof (IEventAggregator), () => proxy.Value);