J. Melis
J. Melis

Reputation: 82

Determining whether or not someone has a webpage open

I am currently working on designing a web application that will be built with MVC4.

The gist of the system is that there is a main view that will show a list of records. Records will be added to the grid as they are generated. The user can open a record in an "edit" type view.

One of the requirements is that if one user has a record open in the "edit" view and another user tries to open the same record the second user will be notified that the first user is currently working on that record.

I have been asked to avoid any kind of locking mechanism. They just want to be notified that someone else has it open.

Is something like this possible? I have been racking my brain but I am at a loss.

Upvotes: 1

Views: 69

Answers (1)

Matías Fidemraizer
Matías Fidemraizer

Reputation: 64943

You should implement it using optimistic locking (actually, no locking... see the link to learn more about this approach) or last to save the record wins.

In the other hand, I believe you should implement that notification the same way as you would do if it was an actual lock, but without locking.

When user A, B, C, D, N starts some record edition, your system should be aware about this and store some temp global state with identifiers of users editing the so-called record. Once you store this data, everyone should be notified in real-time that someone has started to edit that record (f.e. your view might show user names of users being editing the record).

How you would notify everyone about this and in real-time? The answer is SignalR, which is an abstraction over WebSockets and other protocols/approaches to real-time Web development. Check this getting started with SignalR 2 article if you want to learn more about how you would implement SignalR in a real-world project.

Upvotes: 3

Related Questions