Internet Chess ToolKit
v0.2.0

ictk.boardgame.chess.net.ics
Class ICSProtocolHandler

java.lang.Object
  extended byictk.boardgame.chess.net.ics.ICSProtocolHandler
All Implemented Interfaces:
java.lang.Runnable
Direct Known Subclasses:
FICSProtocolHandler

public abstract class ICSProtocolHandler
extends java.lang.Object
implements java.lang.Runnable

The generic connection object. This handles logins, disconnects and chunking the server messages.


Constructor Summary
ICSProtocolHandler()
           
 
Method Summary
 void addConnectionListener(ICSConnectionListener listener)
           
abstract  void connect()
           
abstract  void disconnect()
           
 void dispatchConnectionEvent(ICSConnectionEvent evt)
           
 ICSEventRouter getEventRouter()
          returns the event router being used for this connetion.
 java.lang.String getHandle()
          returns the handle that the user is logged in as.
 java.lang.String getHost()
          gets the name of the host that you want to / or have connected to.
 java.lang.String getPassword()
          returns the password used to login.
 int getPort()
          gets the port number you want to / or have connected to.
 boolean isConnected()
          is the program currently connected to the host.
 boolean isLagCompensated()
          this is true if the connection has, or is currently set to have, lag compensation turned on for the connection.
 boolean isLoggedIn()
          is the user currently logged into the server.
 void removeConnectionListener(ICSConnectionListener listener)
           
abstract  void sendCommand(java.lang.String cmd)
           
abstract  void sendCommand(java.lang.String cmd, boolean echo)
           
 void setEventRouter(ICSEventRouter router)
          sets the object to do the event routing for this connection.
 void setHandle(java.lang.String handle)
          sets the user login handle.
 void setHost(java.lang.String host)
          set the host (server) you want to connect to.
 void setLagCompensation(boolean t)
          sets the connection for lag compensation if t is true.
 void setPassword(java.lang.String password)
          sets the password this user will use to connect.
 void setPort(int port)
          sets the port number you want to connect to.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.lang.Runnable
run
 

Constructor Detail

ICSProtocolHandler

public ICSProtocolHandler()
Method Detail

setHandle

public void setHandle(java.lang.String handle)
sets the user login handle. This must be done before you try to connect to the server.


getHandle

public java.lang.String getHandle()
returns the handle that the user is logged in as. Note: this is the true handle as obtained from the server and may differ from the one set before login. Usually only the case is different.


setPassword

public void setPassword(java.lang.String password)
sets the password this user will use to connect. This must be set before you attempt to log into the server.


getPassword

public java.lang.String getPassword()
returns the password used to login.


setHost

public void setHost(java.lang.String host)
set the host (server) you want to connect to. Setting a bad host will not throw an error until you try to connect.


getHost

public java.lang.String getHost()
gets the name of the host that you want to / or have connected to.


setPort

public void setPort(int port)
sets the port number you want to connect to.


getPort

public int getPort()
gets the port number you want to / or have connected to.


setLagCompensation

public void setLagCompensation(boolean t)
sets the connection for lag compensation if t is true. This can only be done before the connection is established. Any attempt to set this value if there is already a connection to the host will result in an exception being thrown.

Throws:
java.lang.IllegalStateException - if there is an active connection.

isLagCompensated

public boolean isLagCompensated()
this is true if the connection has, or is currently set to have, lag compensation turned on for the connection. This usually means timeseal, timestamp, accuclock, or some other lag compensation program is being used for the connection.


isConnected

public boolean isConnected()
is the program currently connected to the host.


isLoggedIn

public boolean isLoggedIn()
is the user currently logged into the server. This implies that there is currently a connection to the server.


setEventRouter

public void setEventRouter(ICSEventRouter router)
sets the object to do the event routing for this connection. By default a router is setup. But you might want to change it for some reason.


getEventRouter

public ICSEventRouter getEventRouter()
returns the event router being used for this connetion.


connect

public abstract void connect()
                      throws java.net.UnknownHostException,
                             java.io.IOException
Throws:
java.net.UnknownHostException
java.io.IOException

disconnect

public abstract void disconnect()

sendCommand

public abstract void sendCommand(java.lang.String cmd)

sendCommand

public abstract void sendCommand(java.lang.String cmd,
                                 boolean echo)

addConnectionListener

public void addConnectionListener(ICSConnectionListener listener)

removeConnectionListener

public void removeConnectionListener(ICSConnectionListener listener)

dispatchConnectionEvent

public void dispatchConnectionEvent(ICSConnectionEvent evt)

Submit a bug or feature
Visit the Website
Internet Chess ToolKit is licensed under the GPL v2 .