1 package net.pterodactylus.irc;
3 import java.io.IOException;
6 * A connection to an IRC server.
8 * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
10 public interface Connection {
13 * Returns the hostname of the remote end of the connection.
15 * @return The remote’s hostname
20 * Returns the port number of the remote end of the connection.
22 * @return The remote’s port number
27 * Returns whether this connection has already been established.
29 * @return {@code true} as long as this connection is established, {@code
32 boolean established();
35 * Returns the nickname that is currently in use by this connection. The
36 * nickname is only available once the connection has been {@link #start()}ed.
38 * @return The current nickname
43 * Sets the username to use.
47 * @return This connection
49 Connection username(String username);
52 * Sets the real name to use.
55 * The real name to use
56 * @return This connection
58 Connection realName(String realName);
61 * Sets the optional password for the connection.
64 * The password for the connection
65 * @return This connection
67 Connection password(String password);
70 * Returns the current rate of the connection’s incoming side.
72 * @return The current input rate (in bytes per second)
77 * Returns the current rate of the connection’s outgoing side.
79 * @return The current output rate (in bytes per second)
84 * Checks whether the given source is the client represented by this
89 * @return {@code true} if this connection represents the given source, {@code
92 boolean isSource(Source source);
95 * Joins the given channel.
100 * if an I/O error occurs
102 void joinChannel(String channel) throws IOException;
105 * Sends a message to the given recipient, which may be a channel or another
109 * The recipient of the message
112 * @throws IOException
113 * if an I/O error occurs
115 void sendMessage(String recipient, String message) throws IOException;
118 * Sends a DCC RESUME request to the given recipient.
121 * The recipient of the request
123 * The name of the file to resume
125 * The port number from the original DCC SEND request
127 * The position at which to resume the transfer
128 * @throws IOException
129 * if an I/O error occurs
131 void sendDccResume(String recipient, String filename, int port, long position)
135 * Opens the connection and starts processing messages from the other side.
140 * Closes this connection.
142 * @throws IOException
143 * if an I/O error occurs
145 void close() throws IOException;