net.kano.joscar.snaccmd.conn
Class ServiceRedirect

java.lang.Object
  extended bySnacCommand
      extended byConnCommand
          extended byServiceRedirect

public class ServiceRedirect
extends ConnCommand

A SNAC command sent in response to a ServiceRequest to direct the client to an OSCAR server that supports the specified SNAC family.

See Also:
ServiceRequest
Source of this SNAC:
AIM server
SNAC command type:
Family 0x01, command 0x05

Field Summary
 
Fields inherited from class ConnCommand
CMD_CLIENT_READY, CMD_CLIENT_VERS, CMD_ENCINFOACK, CMD_EXTRA_ACK, CMD_MIGRATE_PLS, CMD_MY_INFO_REQ, CMD_NOOP, CMD_PAUSE, CMD_PAUSE_ACK, CMD_RATE_ACK, CMD_RATE_CHG, CMD_RATE_INFO, CMD_RATE_REQ, CMD_RESUME, CMD_SERV_VERS, CMD_SERVER_READY, CMD_SERVICE_REDIR, CMD_SERVICE_REQ, CMD_SET_IDLE, CMD_SETENCINFO, CMD_SETEXTRAINFO, CMD_UPDATE, CMD_WARNED, CMD_YOUR_INFO, FAMILY_CONN, FAMILY_INFO
 
Fields inherited from class SnacCommand
SNACFLAG_DEFAULT
 
Constructor Summary
  ServiceRedirect(int family, java.lang.String host, ByteBlock cookie)
          Creates a new outgoing service redirection command with the given properties and no port field.
  ServiceRedirect(int family, java.lang.String host, int port, ByteBlock cookie)
          Creates a new outgoing service redirection command with the given properties.
protected ServiceRedirect(SnacPacket packet)
          Creates a new service redirect command from the given incoming SNAC packet.
 
Method Summary
 ByteBlock getCookie()
          Returns the login cookie that should be FLAP provided upon connecting to the specified host.
 java.lang.String getRedirectHost()
          Returns the host to which the client should connect for the given service.
 int getRedirectPort()
          Returns the port on which the client should connect to the given host, or -1 if none was specified.
 int getSnacFamily()
          Returns the SNAC family that is supported by the given host.
 java.lang.String toString()
           
 void writeData(java.io.OutputStream out)
          Writes this command's SNAC data block to the given stream.
 
Methods inherited from class SnacCommand
getCommand, getFamily, getFlag1, getFlag2
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ServiceRedirect

protected ServiceRedirect(SnacPacket packet)
Creates a new service redirect command from the given incoming SNAC packet.

Parameters:
packet - the incoming service redirection packet

ServiceRedirect

public ServiceRedirect(int family,
                       java.lang.String host,
                       ByteBlock cookie)
Creates a new outgoing service redirection command with the given properties and no port field.

Parameters:
family - the SNAC family supported by the given server
host - the hostname of the server to connect to
cookie - a login cookie to provide to the given server upon connecting

ServiceRedirect

public ServiceRedirect(int family,
                       java.lang.String host,
                       int port,
                       ByteBlock cookie)
Creates a new outgoing service redirection command with the given properties.

Parameters:
family - the SNAC family supported by the given server
host - the hostname of the server to connect to
port - the port on which to connect to the server, or -1 for none
cookie - a login cookie to provide to the given server upon connecting
Method Detail

getSnacFamily

public final int getSnacFamily()
Returns the SNAC family that is supported by the given host.

Returns:
the SNAC family for which this redirection command is providing a host

getRedirectHost

public final java.lang.String getRedirectHost()
Returns the host to which the client should connect for the given service.

Returns:
the host that supports the given SNAC family

getRedirectPort

public int getRedirectPort()
Returns the port on which the client should connect to the given host, or -1 if none was specified.

Returns:
the port on which the client should connect to the given host

getCookie

public final ByteBlock getCookie()
Returns the login cookie that should be FLAP provided upon connecting to the specified host.

Returns:
a FLAP login cookie for the given host

writeData

public void writeData(java.io.OutputStream out)
               throws java.io.IOException
Description copied from class: SnacCommand
Writes this command's SNAC data block to the given stream. The SNAC data block is the data after the first ten bytes of a SNAC packet.

Specified by:
writeData in class SnacCommand
Parameters:
out - the stream to which to write the SNAC data
Throws:
java.io.IOException - if an I/O error occurs

toString

public java.lang.String toString()