From: Niki Roo Date: Sat, 2 Dec 2017 15:38:00 +0000 (+0100) Subject: Stop remote server fix X-Git-Tag: fanfix-1.6.3~10 X-Git-Url: https://git.nikiroo.be/?a=commitdiff_plain;h=468b960ba378ae71230f475d3e97521e133ec019;p=fanfix.git Stop remote server fix --- 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;