From 7a0a3589a548bba5749fc26455b13127cd7cdd0b Mon Sep 17 00:00:00 2001 From: Fleischer Hanno Date: Sun, 1 Dec 2024 22:14:09 +0100 Subject: [PATCH] trying to fix server ip to use outward ip --- .../src/main/java/pp/mdga/client/ModelSynchronizer.java | 4 +--- .../src/main/java/pp/mdga/client/server/MdgaServer.java | 5 +++++ .../client/src/main/java/pp/mdga/client/view/MainView.java | 6 +----- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/Projekte/mdga/client/src/main/java/pp/mdga/client/ModelSynchronizer.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/ModelSynchronizer.java index 950dfaa6..1ca3cca5 100644 --- a/Projekte/mdga/client/src/main/java/pp/mdga/client/ModelSynchronizer.java +++ b/Projekte/mdga/client/src/main/java/pp/mdga/client/ModelSynchronizer.java @@ -130,9 +130,7 @@ public void setJoin(String ip, int port) { } public void leave() { - LOGGER.log(Level.INFO, "leave"); - app.getAcousticHandler().playSound(MdgaSound.LEAVE); - enter(MdgaState.MAIN); + app.getGameLogic().selectLeave(); } public void enter(MdgaState state) { diff --git a/Projekte/mdga/client/src/main/java/pp/mdga/client/server/MdgaServer.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/server/MdgaServer.java index f63de56a..3522d1e7 100644 --- a/Projekte/mdga/client/src/main/java/pp/mdga/client/server/MdgaServer.java +++ b/Projekte/mdga/client/src/main/java/pp/mdga/client/server/MdgaServer.java @@ -14,6 +14,7 @@ import java.io.IOException; import java.lang.System.Logger; import java.lang.System.Logger.Level; +import java.net.InetAddress; import java.util.Map; import java.util.UUID; import java.util.concurrent.BlockingQueue; @@ -67,6 +68,9 @@ public void run() { private void startServer() { try { LOGGER.log(Level.INFO, "Starting server..."); //NON-NLS + InetAddress localhost; + localhost = InetAddress.getLocalHost(); + String ip = localhost.getHostAddress(); myServer = Network.createServer(port); initializeSerializables(); myServer.start(); @@ -190,6 +194,7 @@ private void messageReceived(HostedConnection source, ClientMessage message) { @Override public void connectionAdded(Server server, HostedConnection hostedConnection) { + System.out.println("new connection " + hostedConnection); //NON-NLS LOGGER.log(Level.DEBUG, "new connection {0}", hostedConnection); //NON-NLS } diff --git a/Projekte/mdga/client/src/main/java/pp/mdga/client/view/MainView.java b/Projekte/mdga/client/src/main/java/pp/mdga/client/view/MainView.java index 6aa5161d..dc5076b5 100644 --- a/Projekte/mdga/client/src/main/java/pp/mdga/client/view/MainView.java +++ b/Projekte/mdga/client/src/main/java/pp/mdga/client/view/MainView.java @@ -102,7 +102,6 @@ private void tryHost() { if(port >= 1 && port <= 65535) { app.getModelSynchronize().setName(startDialog.getName()); - hostDialog.setHostname(Inet4Address.getLocalHost().getHostAddress()); hostDialog.hostServer(); try { Thread.sleep(1000); @@ -117,10 +116,7 @@ private void tryHost() { //app.getAcousticHandler().playSound(MdgaSound.WRONG_INPUT); return; } - } catch (NumberFormatException e) { - //nothing - } catch (UnknownHostException e) { - throw new RuntimeException(e); + } catch (NumberFormatException ignored) { } hostDialog.resetPort();