I am making a web application using Asp.net zero [version 10.2.0] with ABP Framework version 6.2 Frontend is in Angular 11 & Backend APIs in Asp.net core 5.0 whereas Public website is in Asp.net MVC.
I am trying to fetch logged in users on both frontend(Angular) as well as public(Asp.net MVC) website using SignalR to show it on admin dashboard. Both are using same db table ABPUsers. Does anyone have done similar thing using SignalR or other way ?
Any help appreciated
I did something similar with SignalR on ASP.NET (not Core). I overloaded the OnConnected and OnDisconnected methods in the Hub class to keep my own Dictionary of connected clients.
Each client has a header with their login information. In OnConnected, I would parse the header and check if this client is already connected. If they are not, I would add them to the dictionary. In OnDisconnected, I would check if this client is connected and if they are, remove them from the dictionary. This way, the dictionary always has the connected clients.
Note: because a new Hub is created for every new login, the dictionary has to be a singleton or static. I use a static ConcurrentDictionary.
Note 2: SignalR has an internal structure for storing all clients but it is not possible to easily search without modifying the library and has very limited public methods. This is why I used my own Dictionary.