Last post Mar 02, 2017 08:11 AM by Cathy Zou
Mar 01, 2017 05:56 PM|jpro1001|LINK
Anyone know how I can keep track of Signalr reconnections so that I know if a user has stale data that needs to be refreshed? E.g. I have a grid of rows on my web page. I have a timer on my server that will check the database for new records. If a new record
is found for a specific connection it will push a signalr notification to the users grid telling them to refresh the grid. Kind of like how facebook has a popup that says 'new info'. The problem is that if signalr reconnects it can get a new connectionid.
The connectionid won't know what the last record the user has in their grid. Is there some way to send client data on a signalr reconnection event to update this related information? When a user manually refreshes their grid or refreshes the page I store the
connectionid and the last record timestamp on the server. This design can fail for reconnections tho.
Mar 02, 2017 08:11 AM|Cathy Zou|LINK
Is there some way to send client data on a signalr reconnection event to update this related information?
Please try to override OnReconnected method in your hub class, and then you could write your code logic to get connectionid of the user and push data and updated client web page.
public override Task OnReconnected()
//get connectionid of user
//and page information that user visited before
//call client function to push data to current connected user
The problem is that if signalr reconnects it can get a new connectionid.
For user may get a new connectionid issue, we could
map SignalR User to Connections, which could help us know who is current user based on his connectionid.