webfunds.sox
Class TimeSyncRequest

java.lang.Object
  |
  +--webfunds.sox.Encodable
        |
        +--webfunds.sox.Request
              |
              +--webfunds.sox.TimeSyncRequest

public class TimeSyncRequest
extends Request

See Also:
Serialized Form

Field Summary
static java.lang.String name
           
protected  long time
          The time to sync with for this timesync request (Sure, there's a timestamp in the base class (Request), but it's maybe not a good idea to rely on it, considering that this costs nothing)
protected  int version
           
static int VERSION
          The version of the encoded time request.
 
Fields inherited from class webfunds.sox.Request
account, REQ_not_used_yet, REQ_ORIGINAL, REQ_SUBS_ADD_V, req_version, REQ_VERSION, requestId, sig, timestamp
 
Constructor Summary
TimeSyncRequest(byte[] data)
           
TimeSyncRequest(java.lang.String requestId, AccountId acc)
          Create a TimeSync request using the current time
TimeSyncRequest(java.lang.String requestId, AccountId acc, long time)
          Create a TimeSync request using a specified time
 
Method Summary
 void decode(java.io.InputStream is)
          Update this request object with the values from a request encoded as a byte array (such as previously returned from the encode() method of a request object).
 void encode(java.io.OutputStream os)
          Encode a deposit request to an output stream, suitable for using with RequestPacket to send to remote servers (which use the decode() method to re-construct the object).
 Reply errorReply(int e)
          Requests and Replies are Yin and Yang.
 java.lang.String getName()
          Returns the name of the packet as it goes on the wire.
 long getTime()
           
 TimeSyncReply goodReply(long diff)
          Get a good Reply with the Diff set.
 java.lang.String toString()
          Convert this object to a human readable string
 
Methods inherited from class webfunds.sox.Request
equals, getAccountId, getRequestId, getRequestVersion, getTimestamp, getVersion, isSigned, reconstructReply, setRequestVersion, setSignature, verify
 
Methods inherited from class webfunds.sox.Encodable
decode, encode, main, readByteArray, readCertificate, readProperties, readString, writeByteArray, writeCertificate, writeProperties, writeString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

VERSION

public static final int VERSION
The version of the encoded time request. Originally, in Request.VERSION == 2, there were no local versions. We'll call that VERS == 1.

version

protected int version

name

public static final java.lang.String name

time

protected long time
The time to sync with for this timesync request (Sure, there's a timestamp in the base class (Request), but it's maybe not a good idea to rely on it, considering that this costs nothing)
Constructor Detail

TimeSyncRequest

public TimeSyncRequest(java.lang.String requestId,
                       AccountId acc)
Create a TimeSync request using the current time

TimeSyncRequest

public TimeSyncRequest(java.lang.String requestId,
                       AccountId acc,
                       long time)
Create a TimeSync request using a specified time
Parameters:
time - the time to use for the request

TimeSyncRequest

public TimeSyncRequest(byte[] data)
                throws SOXPacketException
Method Detail

getName

public java.lang.String getName()
Description copied from class: Request
Returns the name of the packet as it goes on the wire.
Overrides:
getName in class Request

getTime

public long getTime()

errorReply

public Reply errorReply(int e)
Requests and Replies are Yin and Yang. Each knows about the other. Get a Reply with Errors set.
Overrides:
errorReply in class Request
Tags copied from class: Request
Parameters:
err - is the error number to set the reply to

goodReply

public TimeSyncReply goodReply(long diff)
Get a good Reply with the Diff set.

encode

public void encode(java.io.OutputStream os)
            throws java.io.IOException
Description copied from class: Request
Encode a deposit request to an output stream, suitable for using with RequestPacket to send to remote servers (which use the decode() method to re-construct the object). If the signature is not present, an unsigned request will be encoded. (That is, it is sign()'s responsibility to set the sig to null in order to sign.)
Overrides:
encode in class Request
Tags copied from class: Request
Parameters:
os - the stream on which to send the output
Returns:
byte[] the request in encoded form

decode

public void decode(java.io.InputStream is)
            throws java.io.IOException,
                   SOXPacketException
Description copied from class: Request
Update this request object with the values from a request encoded as a byte array (such as previously returned from the encode() method of a request object). If the signature is not present in the encoded data, the current signature (if any) will be removed. This method is usually used by subclasses to decode the request/timestamp/sig fields.
Overrides:
decode in class Request
Tags copied from class: Request
Parameters:
is - the stream from which to read the request

toString

public java.lang.String toString()
Description copied from class: Request
Convert this object to a human readable string
Overrides:
toString in class Request