From d66af3a112b6c0d53642a3d26a76711e2cd3dea6 Mon Sep 17 00:00:00 2001 From: AleandroPagani Date: Thu, 30 Apr 2026 18:10:11 +0200 Subject: [PATCH] Both TCP and RMI works and receive correctly the model. After receiving the model, it is printed in stdout --- .../polimi/ingsw/gc14/ClientLauncherTUI.java | 28 ++++--------------- .../gc14/Network/TCP/Client/TCPClient.java | 3 +- 2 files changed, 8 insertions(+), 23 deletions(-) diff --git a/src/main/java/it/polimi/ingsw/gc14/ClientLauncherTUI.java b/src/main/java/it/polimi/ingsw/gc14/ClientLauncherTUI.java index 2280b72..4993aeb 100644 --- a/src/main/java/it/polimi/ingsw/gc14/ClientLauncherTUI.java +++ b/src/main/java/it/polimi/ingsw/gc14/ClientLauncherTUI.java @@ -24,7 +24,7 @@ public class ClientLauncherTUI { System.out.println("Selezionare RMI[0] o TCP[1]: "); int networkType = scanner.nextInt(); - scanner.close(); + if (networkType == 0) { RMIClient client = new RMIClient(controller, "localhost", 1099); @@ -36,19 +36,10 @@ public class ClientLauncherTUI { } while(true) { - System.out.flush(); - if (controller.localController.getModel()!=null) { - break; - } - Thread.sleep(500); + int h = scanner.nextInt(); } - System.out.println("Model set\n\n"); - System.out.print("\033[H\033[2J"); - System.out.flush(); - System.out.println(controller.localController.getModel()); - } else if (networkType == 1) { TCPClient client = new TCPClient(controller, "localhost", 8080); @@ -58,19 +49,12 @@ public class ClientLauncherTUI { System.out.println("TCP connection refused\n\n"); } + while(true) { - System.out.flush(); - if (controller.localController.getModel()!=null) { - break; - } - Thread.sleep(500); + int h = scanner.nextInt(); } - System.out.println("Model set\n\n"); - - - System.out.print("\033[H\033[2J"); - System.out.flush(); - System.out.println(controller.localController.getModel()); } + + scanner.close(); } } \ No newline at end of file diff --git a/src/main/java/it/polimi/ingsw/gc14/Network/TCP/Client/TCPClient.java b/src/main/java/it/polimi/ingsw/gc14/Network/TCP/Client/TCPClient.java index 3806ce5..42b2d6c 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Network/TCP/Client/TCPClient.java +++ b/src/main/java/it/polimi/ingsw/gc14/Network/TCP/Client/TCPClient.java @@ -93,10 +93,11 @@ public class TCPClient { System.out.println(event); } else { event.apply(controller.localController); - //clientController.view.update(); TODO + controller.view.render(); } } else if (read instanceof Game model) { controller.setModel(model); + controller.view.render(); } } catch (IOException e) { e.printStackTrace();