|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.zerjio.JIRC.IRCClient
This class allows a higher level of interaction within the IRC client and the IRC server. This class is the cornerstone of the package. Every application which wants to communicate with the IRC server should use this class. It allows sending the basic IRC commands, and even a RAW command (a command that it is not directly implemented). It also is responsible of reading all incoming IRC messages from the server and to deliver it to the appropiate message listeners.
Constructor Summary | |
IRCClient()
Creates a new IRC client without specifying a server nor port to connect |
|
IRCClient(java.lang.String server,
int port)
Creates a new IRC client with a determined server name and port. |
Method Summary | |
void |
addJOINListener(JOINListener listener)
Adds a JOINListener . |
void |
addMsgListener(MsgListener listener)
Adds a MsgListener . |
void |
addNICKListener(NICKListener listener)
Adds a NICKListener . |
void |
addPARTListener(PARTListener listener)
Adds a PARTListener . |
void |
addPINGListener(PINGListener listener)
Adds a PINGListener . |
void |
addPRIVMSGListener(PRIVMSGListener listener)
Adds a PRIVMSGListener . |
void |
addQUITListener(QUITListener listener)
Adds a QUITListener . |
void |
addReplyMsgListener(ReplyMsgListener listener)
Adds a ReplyMsgListener . |
void |
addTOPICListener(TOPICListener listener)
Adds a TOPICListener . |
boolean |
connect()
Makes a connection to the IRC server. |
void |
disconnect()
Breaks the connection with the IRC server. |
int |
getPort()
Returns the server port where the client will connect. |
java.lang.String |
getServer()
Returns the server name |
boolean |
isClosed()
Returns if the connection is closed. |
void |
removeAllJOINListeners()
Removes all JOINListener s that have been previously added. |
void |
removeAllMsgListeners()
Removes all MsgListener s that have been previously added. |
void |
removeAllNICKListeners()
Removes all NICKListener s that have been previously added. |
void |
removeAllPARTListeners()
Removes all PARTListener s that have been previously added. |
void |
removeAllPINGListeners()
Removes all PINGListener s that have been previously added. |
void |
removeAllPRIVMSGListeners()
Removes all PRIVMSGListener s that have been previously added. |
void |
removeAllQUITListeners()
Removes all QUITListener s that have been previously added. |
void |
removeAllReplyMsgListeners()
Removes all ReplyMsgListener s that have been previously added. |
void |
removeAllTOPICListeners()
Removes all TOPICListener s that have been previously added. |
void |
removeJOINListener(JOINListener listener)
Removes a JOINListener that has been previously added. |
void |
removeMsgListener(MsgListener listener)
Removes a MsgListener that has been previously added. |
void |
removeNICKListener(NICKListener listener)
Removes a NICKListener that has been previously added. |
void |
removePARTListener(PARTListener listener)
Removes a PARTListener that has been previously added. |
void |
removePINGListener(PINGListener listener)
Removes a PINGListener that has been previously added. |
void |
removePRIVMSGListener(PRIVMSGListener listener)
Removes a PRIVMSGListener that has been previously added. |
void |
removeQUITListener(QUITListener listener)
Removes a QUITListener that has been previously added. |
void |
removeReplyMsgListener(ReplyMsgListener listener)
Removes a ReplyMsgListener that has been previously added. |
void |
removeTOPICListener(TOPICListener listener)
Removes a TOPICListener that has been previously added. |
void |
run()
Gets all information send by the IRC server continuously. |
void |
sendJOINMessage(java.lang.String channels)
Sends a JOIN message to the IRC server. |
void |
sendJOINMessage(java.lang.String channels,
java.lang.String keys)
Sends a JOIN message to the IRC server. |
void |
sendMessage(IRCMessage msg)
Sends an IRCMessage to the IRC server. |
void |
sendNICKMessage(java.lang.String nick)
Sends a NICK message to the IRC server. |
void |
sendPARTMessage(java.lang.String channels)
Sends a PART message to the IRC server. |
void |
sendPASSMessage()
Sends a PASS message to the IRC server with a random connection password. |
void |
sendPASSMessage(java.lang.String passwd)
Sends a PASS message to the IRC server. |
void |
sendPINGMessage(java.lang.String server1)
Sends a PING message to the IRC server. |
void |
sendPINGMessage(java.lang.String server1,
java.lang.String server2)
Sends a PING message to the IRC server. |
void |
sendPONGMessage(java.lang.String daemon)
Sends a PONG message to the IRC server. |
void |
sendPONGMessage(java.lang.String daemon,
java.lang.String daemon2)
Sends a PONG message to the IRC server. |
void |
sendPRIVMSGMessage(java.lang.String receivers,
java.lang.String message)
Sends a PRIVMSG message to the IRC server. |
void |
sendQUITMessage()
Sends a QUIT message to the IRC server. |
void |
sendQUITMessage(java.lang.String quitMsg)
Sends a QUIT message with an optional text to the IRC server. |
void |
sendRawMessage(java.lang.String msg)
Sends a raw message to the IRC server. |
void |
sendTOPICMessage(java.lang.String channelName)
Sends a TOPIC message to the IRC server to retrieve the topic of a channel. |
void |
sendTOPICMessage(java.lang.String channelName,
java.lang.String topic)
Sends a TOPIC message to the IRC server to set the topic of a channel. |
void |
sendUSERMessage(java.lang.String userName,
java.lang.String hostName,
java.lang.String serverName,
java.lang.String realName)
Sends a USER message to the IRC server. |
void |
setPort(int port)
Sets the server port where will connect the client. |
void |
setServer(java.lang.String server)
Sets the server name |
void |
setServerAndPort(java.lang.String server,
int port)
Sets the server name and port where will connect the client. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public IRCClient()
public IRCClient(java.lang.String server, int port)
server
- The server name (or IP adress)port
- The server port where the client will connect.Method Detail |
public java.lang.String getServer()
public int getPort()
public void setServer(java.lang.String server)
server
- The server namepublic void setPort(int port)
port
- The server portpublic void setServerAndPort(java.lang.String server, int port)
server
- The server nameport
- The server portpublic boolean connect()
true
if the connection is successful.
false
if the conection has failed.public boolean isClosed()
true
if the connection is closed.
false
if the connection is active.public void disconnect()
public void addPINGListener(PINGListener listener)
PINGListener
. It will be placed in the last position between active
PINGListener
s. When a PINGMessage
is received it will be
delivered to all PINGListener
s (see processRawMessage(...)
for more details).
listener
- The PINGListener
to be added.public void removePINGListener(PINGListener listener)
PINGListener
that has been previously added.
listener
- The PINGListener
that should be removed.addPINGListener
public void removeAllPINGListeners()
PINGListener
s that have been previously added.
addPINGListener
public void addPRIVMSGListener(PRIVMSGListener listener)
PRIVMSGListener
. It will be placed in the last position between active
PRIVMSGListener
s. When a PRIVMSGMessage
is received it will be
delivered to all PRIVMSGListener
s (see processRawMessage(...)
for more details).
listener
- The PRIVMSGListener
to be added.public void removePRIVMSGListener(PRIVMSGListener listener)
PRIVMSGListener
that has been previously added.
listener
- The PRIVMSGListener
that should be removed.addPRIVMSGListener
public void removeAllPRIVMSGListeners()
PRIVMSGListener
s that have been previously added.
addPRIVMSGListener
public void addTOPICListener(TOPICListener listener)
TOPICListener
. It will be placed in the last position between active
TOPICListener
s. When a TOPICMessage
is received it will be
delivered to all TOPICListener
s (see processRawMessage(...)
for more details).
listener
- The TOPICListener
to be added.public void removeTOPICListener(TOPICListener listener)
TOPICListener
that has been previously added.
listener
- The TOPICListener
that should be removed.addTOPICListener
public void removeAllTOPICListeners()
TOPICListener
s that have been previously added.
addTOPICListener
public void addPARTListener(PARTListener listener)
PARTListener
. It will be placed in the last position between active
PARTListener
s. When a PARTMessage
is received it will be
delivered to all PARTListener
s (see processRawMessage(...)
for more details).
listener
- The PARTListener
to be added.public void removePARTListener(PARTListener listener)
PARTListener
that has been previously added.
listener
- The PARTListener
that should be removed.addPARTListener
public void removeAllPARTListeners()
PARTListener
s that have been previously added.
addPARTListener
public void addJOINListener(JOINListener listener)
JOINListener
. It will be placed in the last position between active
JOINListener
s. When a JOINMessage
is received it will be
delivered to all JOINListener
s (see processRawMessage(...)
for more details).
listener
- The JOINListener
to be added.public void removeJOINListener(JOINListener listener)
JOINListener
that has been previously added.
listener
- The JOINListener
that should be removed.addJOINListener
public void removeAllJOINListeners()
JOINListener
s that have been previously added.
addJOINListener
public void addQUITListener(QUITListener listener)
QUITListener
. It will be placed in the last position between active
QUITListener
s. When a QUITMessage
is received it will be
delivered to all QUITListener
s (see processRawMessage(...)
for more details).
listener
- The QUITListener
to be added.public void removeQUITListener(QUITListener listener)
QUITListener
that has been previously added.
listener
- The QUITListener
that should be removed.addQUITListener
public void removeAllQUITListeners()
QUITListener
s that have been previously added.
addQUITListener
public void addReplyMsgListener(ReplyMsgListener listener)
ReplyMsgListener
. It will be placed in the last position between active
ReplyMsgListener
s. When a ReplyMessage
is received it will be
delivered to all ReplyMsgListener
s (see processRawMessage(...)
for more details).
listener
- The ReplyMsgListener
to be added.public void removeReplyMsgListener(ReplyMsgListener listener)
ReplyMsgListener
that has been previously added.
listener
- The ReplyMsgListener
that should be removed.addReplyMsgListener
public void removeAllReplyMsgListeners()
ReplyMsgListener
s that have been previously added.
addReplyMsgListener
public void addNICKListener(NICKListener listener)
NICKListener
. It will be placed in the last position between active
NICKListener
s. When a NICKMessage
is received it will be
delivered to all NICKListener
s (see processRawMessage(...)
for more details).
listener
- The NICKListener
to be added.public void removeNICKListener(NICKListener listener)
NICKListener
that has been previously added.
listener
- The NICKListener
that should be removed.addNICKListener
public void removeAllNICKListeners()
NICKListener
s that have been previously added.
addNICKListener
public void addMsgListener(MsgListener listener)
MsgListener
. It will be placed in the last position between active
MsgListener
s. When a IRCMessage
is received it will be
delivered to all MsgListener
s (see processRawMessage(...)
for more details).
listener
- The MsgListener
to be added.public void removeMsgListener(MsgListener listener)
MsgListener
that has been previously added.
listener
- The MsgListener
that should be removed.addMsgListener
public void removeAllMsgListeners()
MsgListener
s that have been previously added.
addMsgListener
public void run()
READING_INTERVAL
.
run
in interface java.lang.Runnable
public void sendPASSMessage(java.lang.String passwd)
passwd
- The connection password. If null
or ""
it will generate a random password.public void sendPASSMessage()
public void sendNICKMessage(java.lang.String nick)
nick
- The nick.public void sendUSERMessage(java.lang.String userName, java.lang.String hostName, java.lang.String serverName, java.lang.String realName)
userName
- The user name.hostName
- The host name.serverName
- The server name.realName
- The real name.public void sendQUITMessage(java.lang.String quitMsg)
quitMsg
- The quit message (the optional text).public void sendQUITMessage()
public void sendPINGMessage(java.lang.String server1)
server1
- The server that must be pinged.public void sendPINGMessage(java.lang.String server1, java.lang.String server2)
server1
- The server that must be pinged.server2
- The PING will be forwarded to this server.public void sendPONGMessage(java.lang.String daemon)
daemon
- Name of the daemon that has responded.public void sendPONGMessage(java.lang.String daemon, java.lang.String daemon2)
daemon
- Name of the daemon that has responded.daemon2
- The PONG message will be forwarded to daemon2.public void sendJOINMessage(java.lang.String channels)
channels
- The channels that must be joinedpublic void sendJOINMessage(java.lang.String channels, java.lang.String keys)
channels
- The channels that must be joinedkeys
- The keys to enter the channels (they are optional).public void sendPARTMessage(java.lang.String channels)
channels
- The channels that must be parted.public void sendTOPICMessage(java.lang.String channelName)
channelName
- The name of the channel that the topic should be retrieved.public void sendTOPICMessage(java.lang.String channelName, java.lang.String topic)
channelName
- The name of the channel that the topic will be set.topic
- The desired topic for the channel.public void sendPRIVMSGMessage(java.lang.String receivers, java.lang.String message)
receivers
- The receivers of the PRIVMSG.message
- The text of the message.public void sendMessage(IRCMessage msg)
IRCMessage
to the IRC server.
msg
- The message to be sended.public void sendRawMessage(java.lang.String msg)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |