X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;ds=sidebyside;f=src%2Fnet%2Fpterodactylus%2Ffcp%2Fhighlevel%2FFcpClient.java;h=21dc647962a8afdba9c91bfbbd6b29d82a21b2f9;hb=84da1f5f1d0169235d1c71991f62af5e08c7263f;hp=bcf529b6dca4a14e26ffa5e4f57c0062ff11f581;hpb=6f8d718b2a9b274e8898ab964b355bf4b349a787;p=jFCPlib.git diff --git a/src/net/pterodactylus/fcp/highlevel/FcpClient.java b/src/net/pterodactylus/fcp/highlevel/FcpClient.java index bcf529b..21dc647 100644 --- a/src/net/pterodactylus/fcp/highlevel/FcpClient.java +++ b/src/net/pterodactylus/fcp/highlevel/FcpClient.java @@ -142,18 +142,21 @@ public class FcpClient { } }; fcpConnection.addFcpListener(fcpListener); - fcpConnection.connect(); - ClientHello clientHello = new ClientHello(name); - fcpConnection.sendMessage(clientHello); - while (true) { - try { - fcpListener.complete(); - break; - } catch (InterruptedException e) { - /* ignore, we’ll loop. */ + try { + fcpConnection.connect(); + ClientHello clientHello = new ClientHello(name); + fcpConnection.sendMessage(clientHello); + while (true) { + try { + fcpListener.complete(); + break; + } catch (InterruptedException e) { + /* ignore, we’ll loop. */ + } } + } finally { + fcpConnection.removeFcpListener(fcpListener); } - fcpConnection.removeFcpListener(fcpListener); if (fcpListener.getFcpException() != null) { throw fcpListener.getFcpException(); }