Expost hostname and port number.
[xudocci.git] / src / main / java / net / pterodactylus / irc / Connection.java
index 530b0c7..0cbbae8 100644 (file)
@@ -144,6 +144,22 @@ public class Connection extends AbstractExecutionThreadService implements Servic
        //
 
        /**
+        * Returns the hostname of the remote end of the connection.
+        * @return The remote’s hostname
+        */
+       public String hostname() {
+               return hostname;
+       }
+
+       /**
+        * Returns the port number of the remote end of the connection.
+        * @return The remote’s port number
+        */
+       public int port() {
+               return port;
+       }
+
+       /**
         * Returns whether this connection has already been established.
         *
         * @return {@code true} as long as this connection is established, {@code
@@ -278,6 +294,16 @@ public class Connection extends AbstractExecutionThreadService implements Servic
                connectionHandler.sendCommand("PRIVMSG", recipient, String.format("\u0001DCC RESUME %s %d %d\u0001", filename, port, position));
        }
 
+       /**
+        * Closes this connection.
+        *
+        * @throws IOException
+        *              if an I/O error occurs
+        */
+       public void close() throws IOException {
+               connectionHandler.close();
+       }
+
        //
        // ABSTRACTEXECUTIONTHREADSERVICE METHODS
        //