Refresh Update Data Sample
This sample demonstrates how changes made to the data by one of the client applications can be instantly
propagated to other clients connected to the same server.
The following steps are performed to achieve the goal:
-
When the user attempts to edit a record the client application calls the remote method of the server to notify
that the row is being edited. Row being edited by one client application will be made unavailable for edit by others to
prevent update conflicts.
-
When the server is informed about a row edit attempt it sends row lock notifications to all clients connected. RO SDK
callback events are used for this purpose. Also the server maintains the list of locked rows to lock rows on the newly connected clients.
-
When the client finishes editing the row it sends changed data to the server as usual and in addition calls the
remote method to inform that the row lock is released.
- The server notifies all clients about releasing the row lock.
-
When row release notification is processed by the client it refetches the changed row from the server.
Dynamic Where is used to fetch particular row.
Examine the code
Examine the client:
- Examine TClientForm.btEditClick event handler to see how the record is edited.
-
See how the client processes row lock notifications, examine TClientForm.OnUpdateAllBlock
and TClientForm.OnUpdateBlock methods.
- See how changed data refresh is performed, examine TClientForm.OnUpdateUnblock method.
Examine the sample server:
- Examine BlockRow service method to see how the row edit attempt is processed.
- Examine BlockSetOfRows to see how the server interacts with newly connected client.
- Examine UnblockRow service method to see how the row change notification is propagated to connected clients.
Getting started
- Run the Sample Server.
- Run two or more instances of the RefreshData sample.
- Load data to every client instance with Load button.
- Click Edit button to edit the row.
-
See how the row being edited on one client instance is marked 'locked' on others. You may try to edit the locked row,
the application will forbid doing this.
- Make some changes to the row being edited and confirm changes in the edit form.
- See how row locks are relesed on the remaining client instances and how the row is updated.
-
While the row is being edited on any client launch one more client instance. See how existing row locks are displayed
on the newly connected client.