简体   繁体   中英

A better approach to persisting information with SignalR

I have an MVC application which enables multiple users to work off the same queue of items.I implemented SignalR to ensure the users don't work on the same item.

This works fine until a new user accesses the page, which of course means that this session hasn't received any information about who's working on what. My initial thought was that perhaps I should set a value in the database record which indicates the item is currently being worked on, and when a new user retrieves the list of items, this information comes along with the dataset.

What are some alternative options to solving this problem? Perhaps a continuous loop of messages to the hub while the user is currently working on an item?

One approach could be that your SignalR hub maintains a list of active items. Then when a new client connects it sends out that list to the new connection(s).

That way when the first get into the site they are presented with the current activity list without re-querying the database.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM