f00f.net.irc.martyr
Class AutoReconnect

java.lang.Object
  |
  +--f00f.net.irc.martyr.GenericAutoService
        |
        +--f00f.net.irc.martyr.AutoReconnect
All Implemented Interfaces:
java.util.Observer

public class AutoReconnect
extends GenericAutoService

AutoReconnect performs the job of reconnecting to the server, if the connection is terminated unexpectedly. AutoReconnect will try to reconnect 5 times, and then give up. If AutoReconnect intercepts a QUIT command before the state change that is issued by us (bounced back from the server) then it will not try to reconnect.

Note that AutoReconnect has no play in nick negotiation, and as such, a failed nick negotiation does not count as a connection retry.


Field Summary
static int DEFAULT_CONNECT_SLEEPTIME
           
static int DEFAULT_MAX_ATTEMPTS
           
 
Constructor Summary
AutoReconnect(IRCConnection connection)
          Initializes with reasonable defaults.
AutoReconnect(IRCConnection connection, int maxAttempts, int sleepBetween)
           
 
Method Summary
protected  void connect()
           
 java.lang.String toString()
           
protected  void updateCommand(Command command)
          AutoReconnect will disable itself if it sees a quit command generated by returned from the server.
protected  void updateState(State state)
           
 
Methods inherited from class f00f.net.irc.martyr.GenericAutoService
disable, enable, getConnection, isEnabled, update
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_MAX_ATTEMPTS

public static final int DEFAULT_MAX_ATTEMPTS

DEFAULT_CONNECT_SLEEPTIME

public static final int DEFAULT_CONNECT_SLEEPTIME
Constructor Detail

AutoReconnect

public AutoReconnect(IRCConnection connection,
                     int maxAttempts,
                     int sleepBetween)
Parameters:
connection - The IRCConnection
maxAttempts - The number of tries to do before giving up
sleepBetween - Milliseconds to sleep between retries

AutoReconnect

public AutoReconnect(IRCConnection connection)
Initializes with reasonable defaults.
Method Detail

connect

protected void connect()
                throws java.io.IOException

updateState

protected void updateState(State state)
Overrides:
updateState in class GenericAutoService

updateCommand

protected void updateCommand(Command command)
AutoReconnect will disable itself if it sees a quit command generated by returned from the server. This usually happens just before the server terminates the connection. Note that this would really be better if we could intercept messages on their way out, but Martyr doesn't do that.
Overrides:
updateCommand in class GenericAutoService

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright ? 2000,2001, f00f networks. All Rights Reserved.