• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

URLyBird - sending updates to the client

 
Jonathan Moore
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone,

I've read a couple of threads about whether to broadcast updates to clients, and agree with most people that this is out of scope of the project. However I'm wondering what to do when a user tries to book a room that has been a room that's recently been updated.

The scenario is

User A performs a search that retuns room Z and shows it as bookable
User B performs the same search
User A books room Z
User B attempts to book room Z

Currently user B will get a message to say that this room is no longer bookable. But how should I update the display? The choices as far as I can see are:

[*]Leave the display exactly as it is. The user would have to redo the search to show the room as booked.
[*]Requery the data just for room Z.
[*]Requery the data for all currently displayed rooms.
[*]Reperform the previous search.

I was considering option 4, but there is the possibility of the data having changed considerably, which may confuse the user if several rows get added or removed. I also have a check box to allow the user to display all rooms or bookable rooms only, but if the user has "bookable only" selected then any of the last three options would cause the selected room to dissapear from the display, so I'm now wondering whether to remove this checkbox and just display all results.

I'd appreciate any thoughts.

Cheers
Jon
 
Jeff Haynes
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jon,

Here is what I do in the scenario you mentioned.


User A performs a search that retuns room Z and shows it as bookable
User B performs the same search
User A books room Z
User B attempts to book room Z


Basically what I do is inform the user(B) that the record has already been booked, and it is no longer bookable, and I perform the same search they have already done. This displays all records matching the criteria, including the one they were just trying to book with all customer values associated to the given records. I am basically making the assumption that the user won't be 'freaked out' by the change in data.. but will understand that there could potentially be many users working on the system at the same time thus causing the scenerio you mentioned.


-Jeff
 
Jonathan Moore
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply Jeff. I think I'll stick with the same solution, but when I inform the user the room is not bookable I'll also inform them the search results are being refreshed.

Cheers
Jon
 
Henri Zwolle
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> Currently user B will get a message to say that this room is no longer bookable.

How does B's client know this?
The required interface in my assignment has this function:

// Modifies the fields of a record. The new value for field n
// appears in data[n]. Throws SecurityException
// if the record is locked with a cookie other than lockCookie.
public void updateRecord(long recNo, String[] data, long lockCookie)
throws RecordNotFoundException, SecurityException;

The only way the server can communicate a result back to the client here is by throwing an exception. (or mangling with the provided String array, but let's not suggest that.)
The serverside could of course throw a RecordNotFoundException whenever a client updates a record that has been booked. But that means that any booking can never be changed.

How did you solve this?
 
Jonathan Moore
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Henri,

I have a business layer, with a book() method. This does the following:

lock record
read record
check bookable
book
unlock

I throw an exception if the room is not bookable.

I certainly don't think you should do this sort of check in the Data class since this is a generic data access class - it doesn't (in my code at least)know anything about the booking system and may be used to update any field (potentially in a different data file with completely different fields).

Hope that helps
Jon
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic