net.kano.joscar.flap
Class FlapPacket

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

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

Represents a FLAP packet, containing a sequence number, channel, and FLAP data.


Field Summary
static int CHANNEL_CLOSE
          The "closing" FLAP channel, channel 4.
static int CHANNEL_ERROR
          The "error" FLAP channel, channel 3.
static int CHANNEL_LOGIN
          The "login" FLAP channel, channel 1.
static int CHANNEL_SNAC
          The "SNAC" FLAP channel, channel 2.
static int MAX_DATA_LEN
          The maximum length of FLAP data contained in a FLAP packet.
 
Method Summary
 int getChannel()
          Returns this packet's FLAP channel.
 ByteBlock getData()
          Returns the FLAP data associated with this packet.
 int getSeqnum()
          Returns this packet's sequence number.
 java.lang.String toString()
           
 void write(java.io.OutputStream out)
          Writes this FLAP packet to the given stream, generating FLAP data from the associated FlapCommand if necessary.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CHANNEL_LOGIN

public static final int CHANNEL_LOGIN
The "login" FLAP channel, channel 1.

See Also:
Constant Field Values

CHANNEL_SNAC

public static final int CHANNEL_SNAC
The "SNAC" FLAP channel, channel 2.

See Also:
Constant Field Values

CHANNEL_ERROR

public static final int CHANNEL_ERROR
The "error" FLAP channel, channel 3.

See Also:
Constant Field Values

CHANNEL_CLOSE

public static final int CHANNEL_CLOSE
The "closing" FLAP channel, channel 4.

See Also:
Constant Field Values

MAX_DATA_LEN

public static final int MAX_DATA_LEN
The maximum length of FLAP data contained in a FLAP packet.

See Also:
Constant Field Values
Method Detail

getSeqnum

public final int getSeqnum()
Returns this packet's sequence number.

Returns:
the sequence number of this packet

getChannel

public final int getChannel()
Returns this packet's FLAP channel.

Returns:
the FLAP channel on which this packet resides

getData

public final ByteBlock getData()
Returns the FLAP data associated with this packet. This may return null if this is an outgoing packet and the FLAP data have not yet been written to a connection, and thus have not yet been stored locally.

Returns:
this packet's FLAP data, or null if the data have not yet been generated

write

public void write(java.io.OutputStream out)
           throws FlapDataLengthException,
                  java.io.IOException
Writes this FLAP packet to the given stream, generating FLAP data from the associated FlapCommand if necessary.

Specified by:
write in interface LiveWritable
Parameters:
out - the stream to which to write
Throws:
FlapDataLengthException - if, during FLAP data generation, the FLAP data length is too large to hold in a FLAP packet
java.io.IOException - if an I/O error occurs

toString

public java.lang.String toString()