com.objexcel.irc
Class IRCController

java.lang.Object
  |
  +--java.awt.Component
        |
        +--com.objexcel.irc.IRCController

public final class IRCController
extends java.awt.Component
implements Sender.OutputStreamLocator

creates a socket with an irc server, lets you send commands to the server dispatching messages received to registered IRCMessageListeners

See Also:
Serialized Form

Field Summary
static int NETWORK_DALNET
          network types.
static int NETWORK_UNDERNET
           
static int NETWORK_UNKNOWN
           
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Constructor Summary
IRCController()
           
 
Method Summary
 void addIRCMessageListener(IRCMessageListener l)
           
 void connect(java.lang.String irc_server, int irc_port, boolean bUseProxy, java.lang.String SOCKSProxyServer, int SOCKSProxyPort, java.io.File _fileServerMessages, java.lang.String localHostName)
          connect to an ircserver
 void disconnect()
          disconnect us from the irc server
 java.lang.String getHostName()
          returns the host name of this machine used for this irc connection.
 IRCParser getIRCParser()
          get the parser that turns messages into events.
 int getIRCPort()
          get the port of the irc server we're connected to
 java.lang.String getIRCServer()
          get the name of the irc server we're connected to
 java.lang.String getLowerNick()
          return the lowercase version of our nick.
 int getNetworkType()
          return the network type.
 java.lang.String getNick()
          same as getLowerNick but will be in the user's preferred case.
 java.io.OutputStream getOutputStream()
          OuputStreamLocator Interface
 Sender getSender()
          returns the sender connected to the IRC server.
 boolean isConnected()
          have we created the socket?
 boolean isConnecting()
          are we trying to connect but without having actually created the socket?
 void postMessage(java.lang.String err, int level)
          pop the message into the event dispatch queue
 void processEvent(java.awt.AWTEvent event)
          picks the event up from the Java queue and passes it to the app
 void removeIRCMessageListener(IRCMessageListener l)
           
 void setNetworkType(int _networkType)
          set the network type.
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, contains, contains, createImage, createImage, deliverEvent, disable, dispatchEvent, doLayout, enable, enable, enableInputMethods, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getName, getParent, getPeer, getPreferredSize, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paint, paintAll, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, remove, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFont, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus, update, validate
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NETWORK_DALNET

public static final int NETWORK_DALNET
network types. Each network implements a different flavour or IRC. If we can figure out which one we are on, you may tailor your parsing or the format of messages you send

NETWORK_UNDERNET

public static final int NETWORK_UNDERNET

NETWORK_UNKNOWN

public static final int NETWORK_UNKNOWN
Constructor Detail

IRCController

public IRCController()
Method Detail

addIRCMessageListener

public void addIRCMessageListener(IRCMessageListener l)

removeIRCMessageListener

public void removeIRCMessageListener(IRCMessageListener l)

processEvent

public void processEvent(java.awt.AWTEvent event)
picks the event up from the Java queue and passes it to the app

getOutputStream

public java.io.OutputStream getOutputStream()
                                     throws java.io.IOException
OuputStreamLocator Interface
Specified by:
getOutputStream in interface Sender.OutputStreamLocator

getHostName

public java.lang.String getHostName()
returns the host name of this machine used for this irc connection.

getNick

public java.lang.String getNick()
same as getLowerNick but will be in the user's preferred case. Why the lower case versions of everything? Lower case is used to key (say) Hashtable access (mixed case can result in the same name different case being a different key). This method saves us unnecssary object allocations.

getLowerNick

public java.lang.String getLowerNick()
return the lowercase version of our nick. This nick is kept synchronised with any nick changes.

getSender

public Sender getSender()
returns the sender connected to the IRC server. Use it to send commands to the server.

getIRCPort

public int getIRCPort()
get the port of the irc server we're connected to

getIRCServer

public java.lang.String getIRCServer()
get the name of the irc server we're connected to

getNetworkType

public int getNetworkType()
return the network type. DIfferent networks support different commands so this can be useful. CUrrently only dalnet and undernet differentiated.

setNetworkType

public void setNetworkType(int _networkType)
set the network type.

getIRCParser

public IRCParser getIRCParser()
get the parser that turns messages into events.

isConnecting

public boolean isConnecting()
are we trying to connect but without having actually created the socket?

isConnected

public boolean isConnected()
have we created the socket?

disconnect

public void disconnect()
disconnect us from the irc server

postMessage

public void postMessage(java.lang.String err,
                        int level)
pop the message into the event dispatch queue

connect

public void connect(java.lang.String irc_server,
                    int irc_port,
                    boolean bUseProxy,
                    java.lang.String SOCKSProxyServer,
                    int SOCKSProxyPort,
                    java.io.File _fileServerMessages,
                    java.lang.String localHostName)
connect to an ircserver
Parameters:
SOCKSProxyServer - is the optional name of the sock (4, sadly) proxy server we'll be connecting through
localHostName - is optional. if specified we will bind this side of the socket to it otherwise we'll use the default one