|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.threerings.presents.client.DeltaCalculator
public class DeltaCalculator
Used to compute the client/server time delta, attempting to account for the network delay experienced when the server sends its current time to the client.
| Field Summary | |
|---|---|
protected long[] |
_deltas
Client/server time delta estimates. |
protected int |
_iter
The number of ping/pong iterations we've made. |
protected PingRequest |
_ping
A reference to the most recently sent ping which we use to obtain the appropriate send stamp when we get the corresponding receive stamp. |
protected static int |
CLOCK_SYNC_PING_COUNT
The number of times we PING during clock sync to try to smooth out network jiggling. |
| Constructor Summary | |
|---|---|
DeltaCalculator()
Constructs a delta calculator which is used to calculate the time delta between the client and server, accounting reasonably well for the delay introduced by sending a timestamp over the network from the server to the client. |
|
| Method Summary | |
|---|---|
long |
getTimeDelta()
Returns the best estimate client/server time-delta. |
boolean |
gotPong(PongResponse pong)
Must be called when the pong response arrives back from the server. |
boolean |
isDone()
Returns true if this calculator has enough data to compute a time delta estimate. |
void |
sentPing(PingRequest ping)
Must be called when a ping message is sent to the server. |
boolean |
shouldSendPing()
Should we send another ping? |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected int _iter
protected long[] _deltas
protected PingRequest _ping
protected static final int CLOCK_SYNC_PING_COUNT
| Constructor Detail |
|---|
public DeltaCalculator()
| Method Detail |
|---|
public boolean shouldSendPing()
public void sentPing(PingRequest ping)
public boolean gotPong(PongResponse pong)
public long getTimeDelta()
public boolean isDone()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||