|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object f00f.net.irc.martyr.GenericCommandAutoService f00f.net.irc.martyr.GenericAutoService f00f.net.irc.martyr.services.AutoReconnect
public class AutoReconnect
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.
Testing note: Does a server send a QUIT before a forceful removal from the network? Should AutoReconnect not intercept QUITs? Certainly not all servers send QUITs even when you QUIT on your own; this class should be put into a command-out chain as well.
Field Summary | |
---|---|
static int |
DEFAULT_CONNECT_SLEEPTIME
|
static boolean |
DEFAULT_DISABLE_ON_QUIT
|
static int |
DEFAULT_MAX_ATTEMPTS
|
Fields inherited from class f00f.net.irc.martyr.GenericCommandAutoService |
---|
connection, enabled |
Constructor Summary | |
---|---|
AutoReconnect(IRCConnection connection)
Initializes with reasonable defaults. |
|
AutoReconnect(IRCConnection connection,
int maxAttempts,
int sleepBetween)
|
|
AutoReconnect(IRCConnection connection,
int maxAttempts,
int sleepBetween,
boolean disableOnQuit)
|
Method Summary | |
---|---|
protected void |
connect()
Attempts a single connection to the server. |
protected void |
connect(java.lang.String server,
int port)
Attempts a single connection to the server. |
protected void |
doConnectionLoop()
Calls connect() followed by failedToConnect(...) until a connection is made. |
protected void |
doConnectionLoop(java.lang.String server,
int port)
Calls connect() followed by failedToConnect(...) until a connection is made, or the service is disabled. |
protected boolean |
failedToConnect(java.lang.Exception error)
Called when a failure to connect occurs. |
protected void |
finalFailure()
Called when the final failure has occurred. |
void |
go(java.lang.String server,
int port)
Attempts to connect, returning only when a connection has been made or repeated connections have failed. |
java.lang.String |
toString()
|
protected void |
updateCommand(InCommand 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, update |
Methods inherited from class f00f.net.irc.martyr.GenericCommandAutoService |
---|
getConnection, isEnabled |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int DEFAULT_MAX_ATTEMPTS
public static final int DEFAULT_CONNECT_SLEEPTIME
public static final boolean DEFAULT_DISABLE_ON_QUIT
Constructor Detail |
---|
public AutoReconnect(IRCConnection connection, int maxAttempts, int sleepBetween, boolean disableOnQuit)
connection
- The IRCConnectionmaxAttempts
- The number of tries to do before giving upsleepBetween
- Milliseconds to sleep between retriesdisableOnQuit
- Automatically disable on quit eventpublic AutoReconnect(IRCConnection connection, int maxAttempts, int sleepBetween)
public AutoReconnect(IRCConnection connection)
connection
- Connection we are associated withMethod Detail |
---|
public void go(java.lang.String server, int port)
server
- Server to connect toport
- Port to connect toprotected void connect() throws java.io.IOException
java.io.IOException
- if we could not connect successfullyprotected void connect(java.lang.String server, int port) throws java.io.IOException
server
- Server to connect toport
- Port to connect to
java.io.IOException
- if we could not connect successfullyprotected void updateState(State state)
updateState
in class GenericAutoService
protected void doConnectionLoop()
protected void doConnectionLoop(java.lang.String server, int port)
server
- Server to connect toport
- Port to connect toprotected void finalFailure()
protected boolean failedToConnect(java.lang.Exception error)
error
- Exception that caused the failure
protected void updateCommand(InCommand command)
updateCommand
in class GenericCommandAutoService
public java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |