X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Firc%2FConnection.java;h=88059ba2ab8b7ce8a56eca0a688cab278ddacc3e;hb=ff99325d519095f49576105b7cd4b330b3bc8902;hp=10edc3cb89b70d7079848dc2e7b13d30e72e8715;hpb=b128f3dd48287d8141150a43ab02459b363c9e25;p=xudocci.git diff --git a/src/main/java/net/pterodactylus/irc/Connection.java b/src/main/java/net/pterodactylus/irc/Connection.java index 10edc3c..88059ba 100644 --- a/src/main/java/net/pterodactylus/irc/Connection.java +++ b/src/main/java/net/pterodactylus/irc/Connection.java @@ -115,6 +115,9 @@ public class Connection extends AbstractExecutionThreadService implements Servic /** The connection handler. */ private ConnectionHandler connectionHandler; + /** Whether the connection has already been established. */ + private boolean established; + /** * Creates a new connection. * @@ -139,6 +142,16 @@ public class Connection extends AbstractExecutionThreadService implements Servic // /** + * Returns whether this connection has already been established. + * + * @return {@code true} as long as this connection is established, {@code + * false} otherwise + */ + public boolean established() { + return established; + } + + /** * Returns the nickname that is currently in use by this connection. The * nickname is only available once the connection has been {@link #start()}ed. * @@ -447,6 +460,7 @@ public class Connection extends AbstractExecutionThreadService implements Servic if ((connectionStatus == 0x0f) && (connectionStatus != oldConnectionStatus)) { /* connection succeeded! */ + established = true; eventBus.post(new ConnectionEstablished(this)); } oldConnectionStatus = connectionStatus; @@ -456,6 +470,7 @@ public class Connection extends AbstractExecutionThreadService implements Servic logger.log(Level.WARNING, "I/O error", ioe1); eventBus.post(new ConnectionClosed(this, ioe1)); } finally { + established = false; logger.info("Closing Connection."); try { Closeables.close(connectionHandler, true);