From 468b960ba378ae71230f475d3e97521e133ec019 Mon Sep 17 00:00:00 2001 From: Niki Roo Date: Sat, 2 Dec 2017 16:38:00 +0100 Subject: [PATCH] Stop remote server fix --- src/be/nikiroo/fanfix/Main.java | 18 +--------------- .../nikiroo/fanfix/library/RemoteLibrary.java | 21 +++++++++++++++++++ 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/src/be/nikiroo/fanfix/Main.java b/src/be/nikiroo/fanfix/Main.java index 671778e..9d462c4 100644 --- a/src/be/nikiroo/fanfix/Main.java +++ b/src/be/nikiroo/fanfix/Main.java @@ -24,7 +24,6 @@ import be.nikiroo.fanfix.supported.BasicSupport; import be.nikiroo.fanfix.supported.BasicSupport.SupportType; import be.nikiroo.utils.Progress; import be.nikiroo.utils.Version; -import be.nikiroo.utils.serial.server.ConnectActionClientObject; import be.nikiroo.utils.serial.server.ServerObject; /** @@ -345,22 +344,7 @@ public class Main { break; } - try { - final String fkey = key; - new ConnectActionClientObject(host, port, true) { - @Override - public void action(Version serverVersion) - throws Exception { - try { - send(new Object[] { fkey, "EXIT" }); - } catch (Exception e) { - Instance.getTraceHandler().error(e); - } - } - }.connect(); - } catch (IOException e) { - Instance.getTraceHandler().error(e); - } + new RemoteLibrary(key, host, port).exit(); break; case REMOTE: exitCode = 255; // should not be reachable (REMOTE -> START) diff --git a/src/be/nikiroo/fanfix/library/RemoteLibrary.java b/src/be/nikiroo/fanfix/library/RemoteLibrary.java index 9453d67..0637032 100644 --- a/src/be/nikiroo/fanfix/library/RemoteLibrary.java +++ b/src/be/nikiroo/fanfix/library/RemoteLibrary.java @@ -270,6 +270,27 @@ public class RemoteLibrary extends BasicLibrary { "Operation not supportorted on remote Libraries"); } + /** + * Stop the server. + */ + public void exit() { + try { + new ConnectActionClientObject(host, port, true) { + @Override + public void action(Version serverVersion) throws Exception { + send(new Object[] { md5, "EXIT" }); + } + + @Override + protected void onError(Exception e) { + Instance.getTraceHandler().error(e); + } + }.connect(); + } catch (IOException e) { + Instance.getTraceHandler().error(e); + } + } + @Override protected List getMetas(Progress pg) { final Progress pgF = pg; -- 2.27.0