Hello, In my app I am caching locally some reference data using localForage.
Ive implement that as a JS service where Angular controllers use it. When data is changed, different controllers fire different events that got handled by the service to refresh data and bring in to cache new updated data from server.
Now, all this happens on the same machine. What if, I want also to refresh data stored in cache on other machines? I need a way from the server-side that when an entity changes, to send a signalR notification so that other cllients could refresh their data.
Can you guide me to a sample code on how to do so with Abp?
Thanks
3 Answer(s)
-
0
Hi,
First you can use OnlineClientManager's GetAllClients to get all online clients, see <a class="postlink" href="https://github.com/aspnetboilerplate/aspnetboilerplate/blob/master/src/Abp/RealTime/OnlineClientManager.cs#L92">https://github.com/aspnetboilerplate/as ... ger.cs#L92</a>.
Then, you can use such method to trigger client side function
foreach (var client in clients) { var signalRClient = GetSignalRClientOrNull(client); if (signalRClient == null) { continue; } signalRClient.refreshCache(); }
But using this approach might not be effective when you have many users online.
Thanks.
-
0
So, when I call refreshCache() that would translate to client side call? Can I see a concrete sample for some running code to just get the idea of how it works?
Thanks
-
0
This is an example usage in AspNet Zero <a class="postlink" href="https://github.com/aspnetzero/aspnet-zero/blob/master/src/MyCompanyName.AbpZeroTemplate.Web/Chat/SignalR/SignalRChatCommunicator.cs">https://github.com/aspnetzero/aspnet-ze ... nicator.cs</a>.
You can search for client side methods to see their codes as well.