If you look at StackOverflow (SO) site, while you are looking at a specific thread and there is some update to that thread, SO pushes the notification to you. That means SO is aware of user context/user action (which thread you are currently seeing). I am trying to build something similar in my ASP.NET web API application using SignalR.
In order to implement this similar behavior, I am performing following steps.
- Every time user views a thread, I make a get call to an endpoint to return thread information along with that, I am maintaining a dictionary which I update every time, this endpoint is called. In this dictionary I store the
context.connectionId
as key andthreadId
as value (keepingthreadId
as value since multiple users can view the same thread at the same time). - Anytime a change is made to any thread, I ask the dictionary to return me all the connectionId (keys) where value == threadId.
- Then I push notification to all the coonectionId's returned in step2.
Questions:
- I feel this is overkill and there might be an easier way to do all this. What is the best approach to handle this scenario?
- Do you think this approach will scale well and application performance will not be impacted.
- Tomorrow if I move to server farm, would this approach will still work ?