If the timers run only on the clients, it can be inconvenient if they are'nt
synchronized. Both clients have a timer about the opponent, and when he or
she makes a move, you can see the timer counting 1:01, 1:02 and then get the
message from the server the opponent made a move at 1:00, and the client
have to correct the time.

Synchronize the time with the server can be made for example:
1. client sends a request to the server to get the server time, and records
the sending time of the request (1:01.5)
2. the server sends back the server time (0:59.3)
3. the client gets  the time and records the time of getting the response
(1:03.1)
Now the client can estimate the network latency by getting the difference of
the 1. and 3. step and dividing by 2. (1:03.1-1:01.5) / 2 = 0:01.6 / 2 =
0:00.8
The latency has to be added to the server time sent by the server and you
are ready. (0:59.3 + 0:00.8 = 1:00.1)
This works if the server is not too busy and the response is generated
immediately.

Cheers
Peter


2011/2/17 Jeff Chimene <[email protected]>

> On Wed, Feb 16, 2011 at 9:41 AM, Magnus <[email protected]>wrote:
>
>> Hi,
>>
>> my chess application needs time handling.
>>
>> As a general rule, all game related timing decisions are done on the
>> server. For example, when a move is made, the move's time is
>> determined and stored on the server.
>>
>> However, the client should have some visual feeling of a "running"
>> clock, i. e. a clock that is update every second.
>>
>> How can I realize this? I need help especially for these questions:
>>
>> - How do I realize the running clock? Do I have to a timer every
>> second, update the display and create a new timer?
>>
>> - As a starting point, the client receives some initial time value, e.
>> g. when a game is loaded, the client receives the information that
>> black has already spent 01:00 (1 hour). However, there is a little gap
>> due to the RPC processing time. First, the server sends back the
>> information "1 hour" to the client. Then, the client starts counting
>> "01:01", "01:02", and so on. However, when the client starts counting,
>> the time may already be at "01:03", depending on the bandwidth of the
>> internet connection. Can one do something about this?
>>
>
> Isn't this chess clock an elapsed time clock? In other words, the clock
> doesn't sync with wall time, or with the server. It doesn't even have to
> take time zone into consideration. The server should be recording elapsed
> time per client. Why is the network transmission time even an issue?
>
> Cheers,
> jec
> --
> You received this message because you are subscribed to the Google Groups
> "Google Web Toolkit" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/google-web-toolkit?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to