Vladimirs Vladimirs - 4 months ago 61
ASP.NET (C#) Question

sending updates to clients with SignalR using publish-subscribe pattern

I have some information that needs to be displayed to users in real-time. Before I had repetitive calls to the server for a fresh data.

Now I am thinking to replace these repetitive calls with SignalR. General idea is to subscribe on the client to the hub which will send updates to all clients when new entry will be added to a database, however I stuck there with general design of that structure.

So I have my WebAPI project and service layer. In the service when new entry is added I am going to raise an event and inside hub catch that event and send updates to all clients.

Is it a right way how these kind things achieved with SignalR? Can somebody explain how I can implement that given that I am using asp.net WebAPI and SimpleInjector.


There are lots of ways of designing pub / sub around SignalR

I created a wrapper for SignalR to solve it in a Event aggregation form

Please see the wiki


Install using nuget

Install-Package SignalR.EventAggregatorProxy 

See the demo project https://github.com/AndersMalmgren/SignalR.EventAggregatorProxy/tree/master/SignalR.EventAggregatorProxy.Demo.MVC4