my chess application should trust only the server time.
However, I have a "shared" class that is used both on server and client. Within this class I determine the current time by creating a new Date object.
When running on the server, this object represents the correct time. When running on the client, I would like to synchronize it with the server before using it.
But how can I tell if I am running on the server or the client?
Below is a short pseudo code for illustration.
Thanks
Magnus
-----
class ChessClock
{
...
private int offset; // "delta" between server and client time
...
private Date getCurrentTime ()
{
Date d = new Date ();
if (!runningOnServer ())
{
long ms = d.getTime () + offset;
d = new Date (ms);
}
}
private boolean runningOnServer ()
{
// how to determine???
}
}
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
No comments:
Post a Comment