net.kano.joscar.flapcmd
Class CloseFlapCmd

java.lang.Object
  extended byFlapCommand
      extended byCloseFlapCmd

public class CloseFlapCmd
extends FlapCommand

A FLAP command sent immediately before a FLAP connection is closed. Note that sending this is always optional, but always means the connection will close immediately. Normally, the server sends this command (possibly with a disconnection code), the client sends an empty one back, and the TCP connection terminates.

FLAP channel:
0x04

Field Summary
static int CHANNEL_CLOSE
          The FLAP channel on which close commands reside.
static int CODE_LOGGED_IN_ELSEWHERE
          A disconnection code indicating that this screenname has been logged into elsewhere, and thus you have been disconnected.
 
Constructor Summary
  CloseFlapCmd()
          Creates a new empty outgoing FLAP close command without a disconnection code or associated URL.
protected CloseFlapCmd(FlapPacket packet)
          Generates a new FLAP close command from the given incoming FLAP packet.
  CloseFlapCmd(int code)
          Creates a new outgoing FLAP close command with the given disconnection code and no associated URL.
  CloseFlapCmd(int code, java.lang.String url)
          Creates a new outgoing FLAP close command with the given disconnection code and related URL.
 
Method Summary
 int getCode()
          Returns the "disconnection code" sent in this close command, or -1 if none was sent.
 java.lang.String getUrl()
          Returns the "error URL" at which a description or support for the given error can be found, or null if no such URL was sent.
 java.lang.String toString()
           
 void writeData(java.io.OutputStream out)
          Writes this command's FLAP data to the given stream.
 
Methods inherited from class FlapCommand
getChannel
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CHANNEL_CLOSE

public static final int CHANNEL_CLOSE
The FLAP channel on which close commands reside.

See Also:
Constant Field Values

CODE_LOGGED_IN_ELSEWHERE

public static final int CODE_LOGGED_IN_ELSEWHERE
A disconnection code indicating that this screenname has been logged into elsewhere, and thus you have been disconnected.

See Also:
Constant Field Values
Constructor Detail

CloseFlapCmd

protected CloseFlapCmd(FlapPacket packet)
Generates a new FLAP close command from the given incoming FLAP packet.

Parameters:
packet - an incoming FLAP close packet

CloseFlapCmd

public CloseFlapCmd()
Creates a new empty outgoing FLAP close command without a disconnection code or associated URL. Using this constructor is equivalent to using new FlapCloseCmd(-1, null).


CloseFlapCmd

public CloseFlapCmd(int code)
Creates a new outgoing FLAP close command with the given disconnection code and no associated URL. Using this constructor is equivalent to using new FlapCloseCmd(code, null).

Parameters:
code - a disconnection code, like CODE_LOGGED_IN_ELSEWHERE, or -1 to indicate that no code should be sent

CloseFlapCmd

public CloseFlapCmd(int code,
                    java.lang.String url)
Creates a new outgoing FLAP close command with the given disconnection code and related URL.

Parameters:
code - a disconnection code, like CODE_LOGGED_IN_ELSEWHERE, or -1 if no code should be sent
url - a (HTTP) URL where a description of this error can be found, or null if no URL should be sent
Method Detail

getCode

public final int getCode()
Returns the "disconnection code" sent in this close command, or -1 if none was sent. Normally CODE_LOGGED_IN_ELSEWHERE or -1.

Returns:
the "disconnection code" sent in this command, or -1 if none was sent

getUrl

public final java.lang.String getUrl()
Returns the "error URL" at which a description or support for the given error can be found, or null if no such URL was sent. Note that AOL's AIM servers only send http://www.aol.com here.

Returns:
an "error URL," or null if none was sent

writeData

public void writeData(java.io.OutputStream out)
               throws java.io.IOException
Description copied from class: FlapCommand
Writes this command's FLAP data to the given stream.

Specified by:
writeData in class FlapCommand
Parameters:
out - the stream to which the FLAP data should be written
Throws:
java.io.IOException - if an I/O error occurs

toString

public java.lang.String toString()