com.objexcel.irc
Class Sender

java.lang.Object
  |
  +--com.objexcel.irc.Sender

public final class Sender
extends java.lang.Object

Sender provides some useful methods for performing common IRC functions There is one sender for the IRC connection and one for each dcc connection. It implements client side flood protection (i.e. you can send lots of messages through it and it slows down the throughput so it shouldn't cause the client to get kicked.) Turned off (not needed) on dcc connections. There are a bunch of methods to make it easier sending standard commands. If that is not your cup of tea, use the sendMsg method with a raw version of your command


Inner Class Summary
static interface Sender.OutputStreamLocator
          an interface that allows us to get the output stream regardless whether it is the irc controller or a dcc connection
static interface Sender.SentDataListener
          an interface so anyone can listen in on what sender is sending
 
Field Summary
static int BANMASK_DOMAIN
           
static int BANMASK_HOST
           
static int BANMASK_MIRC_0
          *!user@host.domain
static int BANMASK_MIRC_1
          *!*user@host.domain
static int BANMASK_MIRC_2
          *!*@host.domain
static int BANMASK_MIRC_3
          *!*user@*.domain
static int BANMASK_MIRC_4
          *!*@*.domain
static int BANMASK_MIRC_5
          nick!user@host.domain
static int BANMASK_MIRC_6
          nick!*user@host.domain
static int BANMASK_MIRC_7
          nick!*@host.domain
static int BANMASK_MIRC_8
          nick!*user@*.domain
static int BANMASK_MIRC_9
          nick!*@*.domain
static int BANMASK_NICK
          the masks to apply to addresses.
static int BANMASK_SIMUSER
           
static int BANMASK_USER
           
static char CTCP_CHAR
          the character that marks a ctcp command
 
Constructor Summary
Sender(IRCController controller, Sender.OutputStreamLocator output)
          OutputStreamLocator's job is to provide a stream to send things too (be it DCC or a connection with an IRC server)
 
Method Summary
 void addSentDataListener(Sender.SentDataListener listener)
          currently only handles one listener
 void doMaskedBanWithOptionalTime(java.lang.String nick, java.lang.String room, int _mask, int banTimeInSeconds)
          this message bans the given nick.
static java.lang.String getMaskedAddress(java.lang.String nick, java.lang.String user, java.lang.String host, int mask)
          returns a masked address.
 void joinServer(java.lang.String ircServer, int ircServerPort, boolean showWarningIfConnected, java.lang.String proxyServer, int proxyServerPort, java.io.File serverMessages, java.lang.String localHost)
          joins the given server but only after gracefully terminating the currenct connections
 void partRoom(java.lang.String sRoom)
          leave the room
 void removeSentDataListener(Sender.SentDataListener listener)
          currently only handles one listener
 void sendAway(java.lang.String sMsg)
          set user away.
 void sendBan(boolean isBanned, java.lang.String sRoom, java.lang.String address)
          send a ban.
 void sendCtcp(boolean asNotice, java.lang.String victim, java.lang.String sMsg)
          send some ctcp command
 void sendCtcpAction(boolean asNotice, java.lang.String victim, java.lang.String msg)
          send a ctcp action (aka the bit after a /me)
 void sendCtcpClientInfoReply(boolean asNotice, java.lang.String victim, java.lang.String supportedCommands)
          send a ctcp client info reply
 void sendCtcpErrMsg(boolean asNotice, java.lang.String victim, java.lang.String msg)
          send a ctcp error message (aka huh?)
 void sendCtcpFingerReply(boolean asNotice, java.lang.String victim, long lastUserSendTime)
          send a ctcp finger reply (actually sends an idle time reply)
 void sendCtcpPingReply(boolean asNotice, java.lang.String victim, java.lang.String data)
          send a ctcp ping reply
 void sendCtcpSourceReply(boolean asNotice, java.lang.String victim)
          send a ctcp client source reply
 void sendCtcpTimeReply(boolean asNotice, java.lang.String victim)
          send a ctcp time reply (aka on the 3 pip the time will be...)
 void sendCtcpUserInfoReply(boolean asNotice, java.lang.String victim, java.lang.String msg)
          send a ctcp user info reply
 void sendCtcpVersionReply(boolean asNotice, java.lang.String victim, java.lang.String version)
          send a ctcp version reply
 void sendGetInfo(java.lang.String victim)
          send a whois and a who
 void sendJoin(java.lang.String sRoom)
          send a join
 void sendJoinWithPassword(java.lang.String sRoom, java.lang.String password)
          send a join and key/password
 void sendList(java.lang.String room, int min, int max)
          request a list of rooms from the server.
 void sendLogin(java.lang.String nick, java.lang.String password, java.lang.String sServer, java.lang.String name)
          send the password, nick and user commands
 void sendMsg(java.lang.String s)
           
 void sendNick(java.lang.String nick)
          send a nick change
 void sendNotice(java.lang.String sRoom, java.lang.String sMsg)
          send a notice
 void sendPart(java.lang.String sRoom)
          send a part
 void sendPong()
          sent in reply to any pings
 void sendPongWithForward(java.lang.String OptForwardTo)
          sent in reply to any pings, forward to another server
 void sendPrivMsg(java.lang.String sTarget, java.lang.String sMsg)
          send a private message to target
 void sendQuit()
          send quit with the default message
 void sendQuit(java.lang.String Msg)
          send a quit
 void setIsDCC(boolean isDCC)
          true if this is a dcc connection.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CTCP_CHAR

public static final char CTCP_CHAR
the character that marks a ctcp command

BANMASK_NICK

public static int BANMASK_NICK
the masks to apply to addresses. Set the mask if you don't want a wildcard

BANMASK_USER

public static int BANMASK_USER

BANMASK_SIMUSER

public static int BANMASK_SIMUSER

BANMASK_HOST

public static int BANMASK_HOST

BANMASK_DOMAIN

public static int BANMASK_DOMAIN

BANMASK_MIRC_0

public static int BANMASK_MIRC_0
*!user@host.domain

BANMASK_MIRC_1

public static int BANMASK_MIRC_1
*!*user@host.domain

BANMASK_MIRC_2

public static int BANMASK_MIRC_2
*!*@host.domain

BANMASK_MIRC_3

public static int BANMASK_MIRC_3
*!*user@*.domain

BANMASK_MIRC_4

public static int BANMASK_MIRC_4
*!*@*.domain

BANMASK_MIRC_5

public static int BANMASK_MIRC_5
nick!user@host.domain

BANMASK_MIRC_6

public static int BANMASK_MIRC_6
nick!*user@host.domain

BANMASK_MIRC_7

public static int BANMASK_MIRC_7
nick!*@host.domain

BANMASK_MIRC_8

public static int BANMASK_MIRC_8
nick!*user@*.domain

BANMASK_MIRC_9

public static int BANMASK_MIRC_9
nick!*@*.domain
Constructor Detail

Sender

public Sender(IRCController controller,
              Sender.OutputStreamLocator output)
OutputStreamLocator's job is to provide a stream to send things too (be it DCC or a connection with an IRC server)
Method Detail

setIsDCC

public void setIsDCC(boolean isDCC)
true if this is a dcc connection. Means we can igore flood control.

addSentDataListener

public void addSentDataListener(Sender.SentDataListener listener)
currently only handles one listener

removeSentDataListener

public void removeSentDataListener(Sender.SentDataListener listener)
currently only handles one listener

partRoom

public void partRoom(java.lang.String sRoom)
leave the room

sendPrivMsg

public void sendPrivMsg(java.lang.String sTarget,
                        java.lang.String sMsg)
send a private message to target

sendAway

public void sendAway(java.lang.String sMsg)
set user away. Null or emty message marks you as back

sendNotice

public void sendNotice(java.lang.String sRoom,
                       java.lang.String sMsg)
send a notice

sendPart

public void sendPart(java.lang.String sRoom)
send a part

sendQuit

public void sendQuit(java.lang.String Msg)
send a quit

sendQuit

public void sendQuit()
send quit with the default message

sendJoin

public void sendJoin(java.lang.String sRoom)
send a join

sendJoinWithPassword

public void sendJoinWithPassword(java.lang.String sRoom,
                                 java.lang.String password)
send a join and key/password

sendBan

public void sendBan(boolean isBanned,
                    java.lang.String sRoom,
                    java.lang.String address)
send a ban. address is either a nick, a fully qualified address (such as nick!khaled@mardam.demon.co.uk) or a masked address such as nick!*user@*.domain
See Also:
getMaskedAddress

sendNick

public void sendNick(java.lang.String nick)
send a nick change

sendLogin

public void sendLogin(java.lang.String nick,
                      java.lang.String password,
                      java.lang.String sServer,
                      java.lang.String name)
send the password, nick and user commands

sendCtcp

public void sendCtcp(boolean asNotice,
                     java.lang.String victim,
                     java.lang.String sMsg)
send some ctcp command

sendGetInfo

public void sendGetInfo(java.lang.String victim)
send a whois and a who

sendCtcpAction

public void sendCtcpAction(boolean asNotice,
                           java.lang.String victim,
                           java.lang.String msg)
send a ctcp action (aka the bit after a /me)

sendCtcpErrMsg

public void sendCtcpErrMsg(boolean asNotice,
                           java.lang.String victim,
                           java.lang.String msg)
send a ctcp error message (aka huh?)

sendCtcpTimeReply

public void sendCtcpTimeReply(boolean asNotice,
                              java.lang.String victim)
send a ctcp time reply (aka on the 3 pip the time will be...)

sendCtcpUserInfoReply

public void sendCtcpUserInfoReply(boolean asNotice,
                                  java.lang.String victim,
                                  java.lang.String msg)
send a ctcp user info reply

sendCtcpClientInfoReply

public void sendCtcpClientInfoReply(boolean asNotice,
                                    java.lang.String victim,
                                    java.lang.String supportedCommands)
send a ctcp client info reply

sendCtcpFingerReply

public void sendCtcpFingerReply(boolean asNotice,
                                java.lang.String victim,
                                long lastUserSendTime)
send a ctcp finger reply (actually sends an idle time reply)
Parameters:
is - the System.currentTimeMillis() when the user last sent something

sendCtcpVersionReply

public void sendCtcpVersionReply(boolean asNotice,
                                 java.lang.String victim,
                                 java.lang.String version)
send a ctcp version reply

sendCtcpSourceReply

public void sendCtcpSourceReply(boolean asNotice,
                                java.lang.String victim)
send a ctcp client source reply

sendCtcpPingReply

public void sendCtcpPingReply(boolean asNotice,
                              java.lang.String victim,
                              java.lang.String data)
send a ctcp ping reply

sendList

public void sendList(java.lang.String room,
                     int min,
                     int max)
request a list of rooms from the server. uses some smarts to see if the network can actuall return only the rooms matching the filter arguments (otherwise ignore the filter arguments) BTW: Dalnet does name filtering, Undernet does the min max

sendPong

public void sendPong()
sent in reply to any pings

sendPongWithForward

public void sendPongWithForward(java.lang.String OptForwardTo)
sent in reply to any pings, forward to another server

joinServer

public void joinServer(java.lang.String ircServer,
                       int ircServerPort,
                       boolean showWarningIfConnected,
                       java.lang.String proxyServer,
                       int proxyServerPort,
                       java.io.File serverMessages,
                       java.lang.String localHost)
joins the given server but only after gracefully terminating the currenct connections

doMaskedBanWithOptionalTime

public void doMaskedBanWithOptionalTime(java.lang.String nick,
                                        java.lang.String room,
                                        int _mask,
                                        int banTimeInSeconds)
this message bans the given nick. It figures out the nicks address (by sending a who) and bansanyone matching the mask you specify.
Parameters:
banTimeInSeconds - has a time in seconds when the ban is lifted. <1 if permanent

getMaskedAddress

public static java.lang.String getMaskedAddress(java.lang.String nick,
                                                java.lang.String user,
                                                java.lang.String host,
                                                int mask)
returns a masked address. The mask values you pass in will be kept. Values you do not pass in will be masked with a wildcard. Mask values can be Or'ed.

sendMsg

public void sendMsg(java.lang.String s)