Both TCP and RMI works and receive correctly the model.
After receiving the model, it is printed in stdout
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user