net.kano.joscar.rvproto.rvproxy
Class RvProxyPacket

java.lang.Object
  extended byRvProxyPacket
All Implemented Interfaces:
LiveWritable

public final class RvProxyPacket
extends java.lang.Object
implements LiveWritable

A data structure used to send and receive commands to and from an AOL Proxy Server.

See Also:
RvProxyCmd, RvProxyCmdFactory

Field Summary
static int CMDTYPE_ACK
          A command type for an acknowledgement packet.
static int CMDTYPE_ERROR
          A command type for error commands.
static int CMDTYPE_INIT_RECV
          A command type for the first command sent to the server when "receiving" a connection over an AOL Proxy Server.
static int CMDTYPE_INIT_SEND
          A command type for the first command sent to the server when creating a connection over an AOL Proxy Server.
static int CMDTYPE_READY
          A command type for a command indicating that the proxy initialization process has finished.
static int FLAGS_DEFAULT_FROM_CLIENT
          The set of flags normally sent by a client connected to an AOL Proxy Server.
static int FLAGS_DEFAULT_FROM_SERVER
          The set of flags normally sent by the AOL Proxy Server.
static int PACKETVERSION_DEFAULT
          A packet version code used by WinAIM by default .
 
Constructor Summary
protected RvProxyPacket(int packetVersion, int cmdType, int flags, ByteBlock data, int totalSize)
          Creates a new AOL Proxy Server packet with the given properties.
  RvProxyPacket(RvProxyCmd rvProxyCmd)
          Creates a new outgoing AOL Proxy Server packet.
 
Method Summary
 ByteBlock getCommandData()
          Returns the "command-specific" data sent in this packet.
 int getCommandType()
          Returns this packet's command type.
 int getFlags()
          Returns the bit flags sent in this packet.
 int getPacketVersion()
          Returns the "packet version" for this packet.
 int getTotalSize()
          Returns the total size of this packet, in bytes, as read from an incoming stream.
static RvProxyPacket readPacket(java.io.InputStream in)
          Reads an AOL Proxy Server packet from the given stream.
 java.lang.String toString()
           
 void write(java.io.OutputStream out)
          Writes a representation of this object to the given stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PACKETVERSION_DEFAULT

public static final int PACKETVERSION_DEFAULT
A packet version code used by WinAIM by default .

See Also:
Constant Field Values

CMDTYPE_ERROR

public static final int CMDTYPE_ERROR
A command type for error commands.

See Also:
Constant Field Values

CMDTYPE_INIT_SEND

public static final int CMDTYPE_INIT_SEND
A command type for the first command sent to the server when creating a connection over an AOL Proxy Server.

See Also:
Constant Field Values

CMDTYPE_INIT_RECV

public static final int CMDTYPE_INIT_RECV
A command type for the first command sent to the server when "receiving" a connection over an AOL Proxy Server.

See Also:
Constant Field Values

CMDTYPE_ACK

public static final int CMDTYPE_ACK
A command type for an acknowledgement packet.

See Also:
Constant Field Values

CMDTYPE_READY

public static final int CMDTYPE_READY
A command type for a command indicating that the proxy initialization process has finished.

See Also:
Constant Field Values

FLAGS_DEFAULT_FROM_SERVER

public static final int FLAGS_DEFAULT_FROM_SERVER
The set of flags normally sent by the AOL Proxy Server.

See Also:
Constant Field Values

FLAGS_DEFAULT_FROM_CLIENT

public static final int FLAGS_DEFAULT_FROM_CLIENT
The set of flags normally sent by a client connected to an AOL Proxy Server.

See Also:
Constant Field Values
Constructor Detail

RvProxyPacket

protected RvProxyPacket(int packetVersion,
                        int cmdType,
                        int flags,
                        ByteBlock data,
                        int totalSize)
Creates a new AOL Proxy Server packet with the given properties.

Parameters:
packetVersion - the "version" code of the packet
cmdType - this packet's command type code
flags - the set of bit flags sent in this packet
data - a block of command-specific data in this packet
totalSize - the total size of this packet, as read from an incoming block of binary data

RvProxyPacket

public RvProxyPacket(RvProxyCmd rvProxyCmd)
Creates a new outgoing AOL Proxy Server packet.

Parameters:
rvProxyCmd - an RvProxyCmd whose properties will be used for this packet
Method Detail

readPacket

public static RvProxyPacket readPacket(java.io.InputStream in)
                                throws java.io.IOException
Reads an AOL Proxy Server packet from the given stream. Note that this method will block until either a complete packet is read, until an invalid packet is read, or until the end of the stream is reached (or until an IOException is thrown). Note that if a complete, valid packet cannot be read, null is returned.
If this method returns null, no guarantees can be made about the contents and state of the given stream; part of a packet may or may not have been read. In general, the right thing to do after this method returns null is to close the underlying stream.

Parameters:
in - the stream from which to read an RV proxy packet
Returns:
a RvProxyPacket read from the given stream, or null if no valid packet could be read
Throws:
java.io.IOException

getPacketVersion

public final int getPacketVersion()
Returns the "packet version" for this packet. This will normally be PACKETVERSION_DEFAULT.

Returns:
this packet's "packet version"

getCommandType

public final int getCommandType()
Returns this packet's command type. This will normally be one of the CMDTYPE_* constants defined in this class.

Returns:
this packet's command type code

getFlags

public final int getFlags()
Returns the bit flags sent in this packet. This will normally be either FLAGS_DEFAULT_FROM_CLIENT or FLAGS_DEFAULT_FROM_SERVER.

Returns:
this packet's set of bit flags

getCommandData

public final ByteBlock getCommandData()
Returns the "command-specific" data sent in this packet. Note that this value will be null if this packet was not read from an incoming stream but was instead created manually.

Returns:
this packet's command-specific data block

getTotalSize

public final int getTotalSize()
Returns the total size of this packet, in bytes, as read from an incoming stream. Note that this value will be -1 if this packet was not read from an incoming stream (via readPacket(java.io.InputStream)).

Returns:
the total size of this packet, in bytes, or -1 if this packet was not read from an incoming stream

write

public void write(java.io.OutputStream out)
           throws java.io.IOException
Description copied from interface: LiveWritable
Writes a representation of this object to the given stream.

Specified by:
write in interface LiveWritable
Parameters:
out - the stream to which to write
Throws:
java.io.IOException - if an I/O error occurs

toString

public java.lang.String toString()