|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.mortbay.cometd.ext.TimesyncExtension
public class TimesyncExtension
Timesync extension (server side). With each handshake or connect, the
extension sends timestamps within the ext field like:
{ext:{timesync:{tc:12345567890,l:23,o:4567},...},...}
where:
A cometd server that supports timesync, can respond with an ext field like:
{ext:{timesync:{tc:12345567890,ts:1234567900,p:123,a:3},...},...}
where:
The relationship between tc, ts, o & l on the server is given by
ts=tc+o+l
(the time the server received the message is the
client time plus the offset plus the network lag). Thus the accuracy of the o
and l settings can be determined with a=tc+o+l-ts
.
When the client has received the response, it can make a more accurate
estimate of the lag as l2=(now-tc-p)/2
(assuming symmetric lag).
A new offset can then be calculated with the relationship on the client that
ts=tc+o2+l2
, thus o2=ts-tc-l2
.
Since the client also receives the a value calculated on the server, it should be possible to analyse this and compensate for some asymmetry in the lag. But the current client does not do this.
Constructor Summary | |
---|---|
TimesyncExtension()
|
Method Summary | |
---|---|
int |
getAccuracyTarget()
timesync responses are not set if the measured accuracy is less than the accuracyTarget. |
org.cometd.Message |
rcv(org.cometd.Client from,
org.cometd.Message message)
|
org.cometd.Message |
rcvMeta(org.cometd.Client from,
org.cometd.Message message)
|
org.cometd.Message |
send(org.cometd.Client from,
org.cometd.Message message)
|
org.cometd.Message |
sendMeta(org.cometd.Client from,
org.cometd.Message message)
|
void |
setAccuracyTarget(int target)
timesync responses are not set if the measured accuracy is less than the accuracyTarget. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public TimesyncExtension()
Method Detail |
---|
public int getAccuracyTarget()
public void setAccuracyTarget(int target)
target
- accuracy target in mspublic org.cometd.Message rcv(org.cometd.Client from, org.cometd.Message message)
rcv
in interface org.cometd.Extension
public org.cometd.Message rcvMeta(org.cometd.Client from, org.cometd.Message message)
rcvMeta
in interface org.cometd.Extension
public org.cometd.Message send(org.cometd.Client from, org.cometd.Message message)
send
in interface org.cometd.Extension
public org.cometd.Message sendMeta(org.cometd.Client from, org.cometd.Message message)
sendMeta
in interface org.cometd.Extension
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |