Stop remote server fix
authorNiki Roo <niki@nikiroo.be>
Sat, 2 Dec 2017 15:38:00 +0000 (16:38 +0100)
committerNiki Roo <niki@nikiroo.be>
Sat, 2 Dec 2017 15:38:00 +0000 (16:38 +0100)
src/be/nikiroo/fanfix/Main.java
src/be/nikiroo/fanfix/library/RemoteLibrary.java

index 671778e60dff4aba78b66a66666be8e285a06653..9d462c402f619246a8ae4854ed1ffe8c185e6250 100644 (file)
@@ -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)
index 9453d674e1df4c18f8ffd959b7f5ab916bf971e9..06370320fb94a6709f543e859841d4e176e4f8de 100644 (file)
@@ -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<MetaData> getMetas(Progress pg) {
                final Progress pgF = pg;