0
votes

I am using CQRS with EventSourcing. I have to use SignalR for updating grid when particular event raised in all opened browsers. So, I have to push data to all clients once Particular event raised.

Currently when user manually refresh page the query is fired which is pulling the data, but I have to pull data without manual refresh using SignalR. I am new to SignalR, Can I get any sample code/reference for implementing the same?

2

2 Answers

4
votes

You could read this article about this topic.

There is also a public repository with some "basic experimentations" with CQRS+ES and SignalR.

Hope this helps

0
votes

First, you must create a Hub class so clients can connect to.

Then, in your event handler you do:

var hubContext = GlobalHost.ConnectionManager.GetHubContext<YourHub>(); hubContext.Clients.All.callJavaScriptFunction(parameters);

This way, when the event handler gets executed, SignalR will call the client methods you want with the data you provide.

You must also create the proper connection from the client and define callJavaScriptFunction.

Note: If you are using dependency injection, you might see very unstable behavior from GlobalHost. Let me know if it is the case.

Hope this helps!

Best of luck!