sashenka.irc
Class IRCConnection

java.lang.Object
  |
  +--sashenka.irc.IRCConnection
All Implemented Interfaces:
IRCClientHandler, java.lang.Runnable

public class IRCConnection
extends java.lang.Object
implements java.lang.Runnable, IRCClientHandler


Constructor Summary
IRCConnection(java.lang.String host, int port, IRCConnectionHandler handler)
          Construct a new IRCConnection and connect it to the given host/port.
 
Method Summary
 void close(java.lang.String why)
          Send a quit message to the remote end.
 void join(Channel channel)
           
 void join(Channel[] channels)
           
 void part(Channel channel)
           
 java.lang.String receive()
          Read the next message from the server.
 void run()
          Enter into a loop continually reading from and dispatching the incoming messages to the handler.
 void send(java.lang.String message)
          Send a propery formatted IRC command message to the server.
 void sendNamesRequest(Channel c)
           
 void sendNotice(Destination to, java.lang.String message)
           
 void sendPrivMsg(Destination[] to, java.lang.String message)
           
 void sendPrivMsg(Destination to, java.lang.String message)
           
 void whois(IRCUser user)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IRCConnection

public IRCConnection(java.lang.String host,
                     int port,
                     IRCConnectionHandler handler)
              throws java.io.IOException,
                     java.net.UnknownHostException
Construct a new IRCConnection and connect it to the given host/port. The handler will be used for all incoming connections. Once constructed, the IRCConnection should be given a thread to run it's run method so that it may begin reading and dispatching messages.

Method Detail

close

public void close(java.lang.String why)
Send a quit message to the remote end. TODO: Close the socket and clean up.


send

public void send(java.lang.String message)
Send a propery formatted IRC command message to the server. This method should only be used if you really know what you are doing. It appends the CR-LF to the command and transmits it verbatim.


receive

public java.lang.String receive()
                         throws java.io.IOException
Read the next message from the server.

java.io.IOException

run

public void run()
Enter into a loop continually reading from and dispatching the incoming messages to the handler. This method returns when no more data is available from the server.

Specified by:
run in interface java.lang.Runnable

join

public void join(Channel[] channels)
Specified by:
join in interface IRCClientHandler

whois

public void whois(IRCUser user)

join

public void join(Channel channel)
Specified by:
join in interface IRCClientHandler

part

public void part(Channel channel)

sendPrivMsg

public void sendPrivMsg(Destination[] to,
                        java.lang.String message)
Specified by:
sendPrivMsg in interface IRCClientHandler

sendPrivMsg

public void sendPrivMsg(Destination to,
                        java.lang.String message)
Specified by:
sendPrivMsg in interface IRCClientHandler

sendNamesRequest

public void sendNamesRequest(Channel c)

sendNotice

public void sendNotice(Destination to,
                       java.lang.String message)
Specified by:
sendNotice in interface IRCClientHandler