Browse Source

fix npe (why has this ever worked?!)

Martin Kunz 2 years ago
parent
commit
2afc311074

+ 6 - 4
src/main/java/at/acdp/urweb/Main.java

@@ -1,11 +1,11 @@
 package at.acdp.urweb;
 
-import at.acdp.urweb.fhpp.FHMaster;
 import at.acdp.urweb.fhpp.FHMasterSim;
 import at.acdp.urweb.fhpp.FHPP;
 import at.acdp.urweb.fhpp.IFHMaster;
-import at.acdp.urweb.web.XRServer;
+import at.acdp.urweb.web.FestoXRServer;
 import com.nmote.nanohttp.NanoServer;
+import com.nmote.xr.HTTPServerEndpoint;
 import com.nmote.xr.XR;
 import org.slf4j.LoggerFactory;
 
@@ -16,8 +16,10 @@ public class Main {
         Params app = null;
         try {
             app = picocli.CommandLine.populateCommand(new Params(), args);
-            NanoServer server = new NanoServer(app.port);
-            server.add(XR.server(XRServer.class));
+            NanoServer server = new NanoServer("http://0.0.0.0:" + app.port);
+            FestoXRServer fxrs = new FestoXRServer();
+            HTTPServerEndpoint xrs = XR.server(fxrs, FestoXRServer.class);
+            server.add(xrs);
             server.start();
         } catch (Exception e) {
             logger.error("Server exited", e);

+ 2 - 5
src/main/java/at/acdp/urweb/web/XRServer.java

@@ -7,8 +7,8 @@ import org.slf4j.LoggerFactory;
 
 import java.util.concurrent.ExecutionException;
 
-public class XRServer {
-    private final static Logger logger = LoggerFactory.getLogger(XRServer.class);
+public class FestoXRServer {
+    private final static Logger logger = LoggerFactory.getLogger(FestoXRServer.class);
 
     @XRMethod(value = "example.helloWorld", help = "Returns 'Helo ' + argument")
     public static String hello(Object s) {
@@ -58,9 +58,6 @@ public class XRServer {
     @XRMethod(value = "abs", help = "abs")
     public boolean abs(int targetPos, int speed) {
         try {
-
-
-
             logger.info("Absolute to {} speed {}", targetPos, speed);
             Main.fhm.bereitschaft();
             if(!Main.fhm.readStatus().get().enabled) {