public interface IRCConnection
Typical usage:
IRCConfig config = IRCConfigBuilder.newBuilder()
.host("irc.freenode.net")
.port(6667)
.username(System.getProperty("user.name"))
.password("secret")
.realname(System.getProperty("user.name"));
IRCConnection connection = IRCConnectionFactory.newConnection(config);
connection.addIRCEventListener(new IRCEventAdapter() {
/* implement whatever you need */
});
connection.connect();
connection.doJoin("#test");
connection.doPrivmsg("#test", "Hello World!");
connection.close();
| Modifier and Type | Field and Description |
|---|---|
static int |
INVALID_TIMEOUT
Value returned when there is no timeout to deliver.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addIRCEventListener(IRCEventListener l)
Adds a new
IRCEventListener which listens for actions coming from
the IRC server. |
void |
close()
Close the connection forcefully.
|
void |
connect()
Establish a connection to the server.
|
void |
doAway()
Removes away message.
|
void |
doAway(String msg)
Sets away message.
|
void |
doInvite(String nick,
String chan)
Invites a user to a channel.
|
void |
doIson(String nick)
Checks if one or more nicks are used on the server.
|
void |
doJoin(String chan)
Joins a channel without a key.
|
void |
doJoin(String chan,
String key)
Joins a channel with a key.
|
void |
doKick(String chan,
String nick)
Kicks a user from a channel.
|
void |
doKick(String chan,
String nick,
String msg)
Kicks a user from a channel with a comment.
|
void |
doList()
Lists all channels with their topic and status.
|
void |
doList(String chan)
Lists channel(s) with their topic and status.
|
void |
doMode(String chan)
Requests a Reply 324 for the modes of a given channel.
|
void |
doMode(String target,
String mode)
Sends a mode to the server.
|
void |
doNames()
Lists all visible users.
|
void |
doNames(String chan)
Lists all visible users of (a) channel(s).
|
void |
doNick(String nick)
Changes the nickname.
|
void |
doNotice(String target,
String msg)
Notices a message to a person or a channel.
|
void |
doPart(String chan)
Parts from a given channel.
|
void |
doPart(String chan,
String msg)
Parts from a given channel with a given parg-msg.
|
void |
doPong(String ping)
Quits from the IRC server with a quit-msg.
|
void |
doPrivmsg(String target,
String msg)
Sends a message to a person or a channel.
|
void |
doQuit()
Quits from the IRC server.
|
void |
doQuit(String msg)
Quits from the IRC server with a quit-msg.
|
void |
doTopic(String chan)
Requests the topic of a chan.
|
void |
doTopic(String chan,
String topic)
Changes the topic of a chan.
|
void |
doUserhost(String nick)
Requires host-information about up to 5 users which must be listed and
divided by spaces.
|
void |
doWho(String criteric)
Requests information about users matching the given criteric, for example
a channel they are on.
|
void |
doWhois(String nick)
Requires information about an existing user.
|
void |
doWhowas(String nick)
Requires host-information about a user, who is not connected anymore.
|
InetAddress |
getLocalAddress()
Returns the local address of the connection socket.
|
String |
getNick()
Returns the nickname of this instance.
|
int |
getPort()
Returns the port to which the
IRCConnection connected, or
0 if the connection failed or wasn't tried yet. |
int |
getTimeout()
Returns the timeout of the socket.
|
boolean |
isConnected()
Tells whether there's a connection to the IRC network or not.
|
boolean |
isSSL() |
boolean |
removeIRCEventListener(IRCEventListener l)
Removes the first occurence of the given
IRCEventListener from
the listener-vector. |
void |
send(String line)
Sends a String to the server.
|
static final int INVALID_TIMEOUT
void addIRCEventListener(IRCEventListener l)
IRCEventListener which listens for actions coming from
the IRC server.l - An instance of the IRCEventListener interface.IllegalArgumentException - If listener is null.void close()
This method does not send QUIT IRC command. Consider
using doQuit() or doQuit(String) to send the proper
QUIT command to the server.
This method should be used only when there is a good reason for that,
e.g. that the IRC server does not react to QUIT command.
Possibly occuring IOExceptions are handled according to the
set exception handling.
connect(),
doQuit(),
doQuit(String)void connect()
throws IOException,
KeyManagementException,
NoSuchAlgorithmException
It tries all ports from IRCServerConfig.getPorts() until the connecting
succeeds. If all ports fail an IOException is thrown.
This method can be invokde once only.
IOException - If an I/O error occurs.NoSuchAlgorithmException - rethrown from the SSL layerKeyManagementException - rethrown from the SSL layerSocketException - If the connect method was already invoked.isConnected(),
doQuit(),
doQuit(String),
close()void doAway()
void doAway(String msg)
msg - The away message.void doInvite(String nick, String chan)
nick - The nickname of the user who should be invited.chan - The channel the user should be invited to.void doIson(String nick)
nick - The nickname of the user we search for.void doJoin(String chan)
chan - The channel which is to join.void doJoin(String chan, String key)
chan - The channel which is to join.key - The key of the channel.void doKick(String chan, String nick)
chan - The channel somebody should be kicked from.nick - The nickname of the user who should be kicked.void doKick(String chan, String nick, String msg)
chan - The channel somebody should be kicked from.nick - The nickname of the user who should be kicked.msg - The optional kickmessage.void doList()
void doList(String chan)
chan - The channel the LIST refers to.void doMode(String chan)
chan - The channel the MODE request is refering to.void doMode(String target, String mode)
String mode must contain the operators (+/-), the modes
(o/v/i/k/l/p/s/w) and the possibly values (nicks/banmask/limit/key).target - The nickname or channel of the user whose modes will be
changed.mode - The new modes.void doNames()
void doNames(String chan)
chan - The channel the NAMES command is refering to.void doNick(String nick)
nick - The new nickname.void doNotice(String target, String msg)
target - The nickname or channel (group) the message should be sent to.msg - The message which should be transmitted.void doPart(String chan)
chan - The channel you want to part from.void doPart(String chan, String msg)
chan - The channel you want to part from.msg - The optional partmessage.void doPong(String ping)
ping - The ping which was received in onPing. It's a
String, because sometimes on some networks the
server-hostname (for example splatterworld.quakenet.org) is
given as parameter which would throw an Exception if we gave
the ping as long.void doPrivmsg(String target, String msg)
target - The nickname or channel the message should be sent to.msg - The message which should be transmitted.void doQuit()
disconnect-method which
does the work actually.isConnected(),
connect(),
doQuit(String),
close()void doQuit(String msg)
disconnect-method which does the work actually.msg - The optional quitmessage.isConnected(),
connect(),
doQuit(),
close()void doTopic(String chan)
chan - The channel which topic should be requested.void doTopic(String chan, String topic)
chan - The channel which topic is changed.topic - The new topic.void doUserhost(String nick)
nick - The nickname of the user the query is refering to.void doWho(String criteric)
criteric - The criterics of the WHO query.void doWhois(String nick)
nick - The nickname of the user the query is refering to.void doWhowas(String nick)
nick - The nickname of the user the query is refering to.InetAddress getLocalAddress()
null is returned.String getNick()
int getPort()
IRCConnection connected, or
0 if the connection failed or wasn't tried yet.IRCConnection, or
0 if the connection failed or wasn't tried yet.int getTimeout()
-1 is returned.
The possibly occuring IOException are handled according to
the set exception handling.boolean isConnected()
connect wasn't called yet, it returns false.true if it's
connected.connect(),
doQuit(),
doQuit(String),
close()boolean isSSL()
true if the connection is using SSLboolean removeIRCEventListener(IRCEventListener l)
IRCEventListener from
the listener-vector.l - An instance of the IRCEventListener interface.true if the listener was successfully removed;
false if it was not found.void send(String line)
do* methods (like
doJoin). A carriage return line feed (\r\n) is
appended automatically.line - The line which should be send to the server without the
trailing carriage return line feed (\r\n).Copyright © 2006–2015. All rights reserved.