|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectnet.jackofalltrades.irc.BaseConnection
net.jackofalltrades.irc.IrcConnection
Provides functionality for receiving, and sending, IRC commands.
// create a new IrcConnection to "irc.darkmyst.org" on port 6667.
IrcConnection darkMyst = new IrcConnection(
InetAddress.getByName("irc.darkmyst.org"), 6667);
// add ConnectionListeners and IrcCommandListeners.
// connect to "irc.darkmyst.org".
for (int i = 5; ((!darkMyst.connect()) && (i > 0)); i--) {
Thread.sleep(1000); // sleep for a second between connection attempts.
}
// perform tasks.
darkMyst.disconnect();
| Field Summary |
| Fields inherited from class net.jackofalltrades.irc.BaseConnection |
DEFAULT_BUFFER_SIZE, DEFAULT_CONNECTION_TIMEOUT, DEFAULT_READ_WRITE_TIMEOUT, MAX_PORT, MIN_PORT |
| Constructor Summary | |
IrcConnection()
Creates a new IrcConnection. |
|
IrcConnection(java.net.InetAddress remoteHost,
int port)
Creates a new IrcConnection to connect to the specified
remote host. |
|
IrcConnection(java.net.Socket socket)
Creates a new IrcConnection connected on the specified
java.net.Socket. |
|
IrcConnection(java.lang.String remoteHost,
int port)
Creates a new IrcConnection to connect to the specified
remote host. |
|
| Method Summary | |
void |
addIrcCommandListener(IrcCommandListener l)
Registers an IrcCommandListener for all commands. |
void |
addIrcCommandListener(java.lang.String name,
IrcCommandListener l)
Registers an IrcCommandListener for specific commands. |
void |
commandPrepared(IrcCommandEvent event)
Writes an IrcCommand to the output stream. |
void |
commandReceived(IrcCommandEvent event)
Does nothing. |
protected void |
processInput()
Reads the commands from the , and notifies IrcCommandListeners events. |
void |
removeIrcCommandListener(IrcCommandListener l)
Removes an IrcCommandListener from the list of registered
listeners for all commands. |
void |
removeIrcCommandListener(java.lang.String name,
IrcCommandListener l)
Removes an IrcCommandListener from the list of registered
listeners for specific commands. |
protected void |
wrapInput(java.io.InputStream input)
Wraps the InputStream in a java.io.Reader. |
protected void |
wrapOutput(java.io.OutputStream output)
Wraps the OutputStream in a java.io.Writer. |
| Methods inherited from class net.jackofalltrades.irc.BaseConnection |
addConnectionListener, addEventListener, connect, disconnect, getBufferSize, getConnectionTimeout, getEventListeners, getLastException, getPortNumber, getReadWriteTimeout, getRemoteHost, isConnected, removeConnectionListener, removeEventListener, run, setBufferSize, setConnectionTimeout, setLastException, setPortNumber, setReadWriteTimeout, setRemoteHost |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public IrcConnection()
IrcConnection.
public IrcConnection(java.net.InetAddress remoteHost,
int port)
IrcConnection to connect to the specified
remote host.
remoteHost - the java.net.InetAddress of the remote
host.port - the port number on the remote host.
java.lang.IllegalArgumentException - if remoteHost is
null, or blank, or if port is not in the
range 1 - 65535.
public IrcConnection(java.lang.String remoteHost,
int port)
throws java.net.UnknownHostException
IrcConnection to connect to the specified
remote host.
remoteHost - the name of the remote host.port - the port number on the server.
java.net.UnknownHostException - if the remoteHost
cannot be resolved.
java.lang.IllegalArgumentException - if the remoteHost
null or blank.public IrcConnection(java.net.Socket socket)
IrcConnection connected on the specified
java.net.Socket.
socket - the Socket connected to the remote host.| Method Detail |
protected void processInput()
throws java.io.IOException
IrcCommandListeners events.
processInput in class BaseConnectionjava.io.IOException - if an I/O error occurs.protected void wrapInput(java.io.InputStream input)
InputStream in a java.io.Reader.
wrapInput in class BaseConnectioninput - the InputStream from the underlying
java.net.Socket.protected void wrapOutput(java.io.OutputStream output)
OutputStream in a java.io.Writer.
wrapOutput in class BaseConnectionoutput - the OutputStream from the underlying
java.net.Socket.public void commandPrepared(IrcCommandEvent event)
IrcCommand to the output stream.
commandPrepared in interface IrcCommandListenerevent - the event fired by a command generating component.public void commandReceived(IrcCommandEvent event)
commandReceived in interface IrcCommandListenerpublic void addIrcCommandListener(IrcCommandListener l)
IrcCommandListener for all commands.
l - the new registered listener.
public void addIrcCommandListener(java.lang.String name,
IrcCommandListener l)
IrcCommandListener for specific commands.
l - the new registered listener.public void removeIrcCommandListener(IrcCommandListener l)
IrcCommandListener from the list of registered
listeners for all commands.
l - the listener to remove.
public void removeIrcCommandListener(java.lang.String name,
IrcCommandListener l)
IrcCommandListener from the list of registered
listeners for specific commands.
l - the listener to remove.
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||