org.mortbay.cometd.ext
Class TimesyncExtension

java.lang.Object
  extended by org.mortbay.cometd.ext.TimesyncExtension
All Implemented Interfaces:
org.cometd.Extension

public class TimesyncExtension
extends Object
implements org.cometd.Extension

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:

The accuracy of the offset and lag may be calculated with tc-now-l-o, which should be zero if the calculated offset and lag are perfectly accurate.

A cometd server that supports timesync, should respond only if the measured accuracy value is greater than accuracy target. The response will be an ext field like: {ext:{timesync:{tc:12345567890,ts:1234567900,p:123,a:3},...},...} where:

On receipt of the response, the client is able to use current time to determine the total trip time, from which p is subtracted to determine an approximate two way network traversal time. The measured accuracy is used to adjust the assumption that the network is symmetric for traversal time, so:


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

TimesyncExtension

public TimesyncExtension()
Method Detail

getAccuracyTarget

public int getAccuracyTarget()
timesync responses are not set if the measured accuracy is less than the accuracyTarget.

Returns:
accuracy target in ms (default 25ms)

setAccuracyTarget

public void setAccuracyTarget(int target)
timesync responses are not set if the measured accuracy is less than the accuracyTarget.

Parameters:
target - accuracy target in ms

rcv

public org.cometd.Message rcv(org.cometd.Client from,
                              org.cometd.Message message)
Specified by:
rcv in interface org.cometd.Extension

rcvMeta

public org.cometd.Message rcvMeta(org.cometd.Client from,
                                  org.cometd.Message message)
Specified by:
rcvMeta in interface org.cometd.Extension

send

public org.cometd.Message send(org.cometd.Client from,
                               org.cometd.Message message)
Specified by:
send in interface org.cometd.Extension

sendMeta

public org.cometd.Message sendMeta(org.cometd.Client from,
                                   org.cometd.Message message)
Specified by:
sendMeta in interface org.cometd.Extension


Copyright © 1995-2009 Mort Bay Consulting. All Rights Reserved.