Object locking over Internet

  softwareengineering

I am building a tutoring application that can be used to draw objects and then one is able to drag them around. I would like to know what is the best thing to do when someone clicks on an object and starts to drag it.

I was told I should “lock” it – prevent it from being grabbed by someone else at the same time and being able to drag it. But that would require sending a request to the server (and then to all other users connected to the tutoring session) to lock it which might take a bit of time (what if a teacher is in USA and student is in Africa on dialup)? I was also told I should loop until I see that the object was locked by me. This way, the user might not be able to grab and drag and object for several seconds (UX design problem).

I proposed perhaps to only enable one to drag object you drew, but that seems short sided. Any suggestions? Thank you!

2

The way a lot of online real time games deal with latency is to go ahead and perform an action locally, then correct it later when the authoritative result is given by the central server. In your case, you start dragging the object locally, sending a lock request to the server as soon as your drag starts, but acting as though you already own the lock. If the lock request succeeds, you carry on as normal. If someone else beat you to it, the local client ends the drag and gives control of the drag to the winning user until the lock is released. None of the other users will see your aborted drag attempt.

You’ll have to decide for yourself if having someone “steal” your drag on rare occasions is more annoying or less than having to wait for a lock every single time. In my opinion, removing the delay in the most common case is the preferred solution.

4

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website

LEAVE A COMMENT