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]: ");
|
System.out.println("Selezionare RMI[0] o TCP[1]: ");
|
||||||
int networkType = scanner.nextInt();
|
int networkType = scanner.nextInt();
|
||||||
|
|
||||||
scanner.close();
|
|
||||||
|
|
||||||
if (networkType == 0) {
|
if (networkType == 0) {
|
||||||
RMIClient client = new RMIClient(controller, "localhost", 1099);
|
RMIClient client = new RMIClient(controller, "localhost", 1099);
|
||||||
@@ -36,19 +36,10 @@ public class ClientLauncherTUI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
while(true) {
|
while(true) {
|
||||||
System.out.flush();
|
int h = scanner.nextInt();
|
||||||
if (controller.localController.getModel()!=null) {
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
Thread.sleep(500);
|
|
||||||
}
|
|
||||||
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) {
|
} else if (networkType == 1) {
|
||||||
TCPClient client = new TCPClient(controller, "localhost", 8080);
|
TCPClient client = new TCPClient(controller, "localhost", 8080);
|
||||||
@@ -58,19 +49,12 @@ public class ClientLauncherTUI {
|
|||||||
System.out.println("TCP connection refused\n\n");
|
System.out.println("TCP connection refused\n\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
while(true) {
|
while(true) {
|
||||||
System.out.flush();
|
int h = scanner.nextInt();
|
||||||
if (controller.localController.getModel()!=null) {
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
Thread.sleep(500);
|
|
||||||
}
|
}
|
||||||
System.out.println("Model set\n\n");
|
|
||||||
|
|
||||||
|
scanner.close();
|
||||||
System.out.print("\033[H\033[2J");
|
|
||||||
System.out.flush();
|
|
||||||
System.out.println(controller.localController.getModel());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -93,10 +93,11 @@ public class TCPClient {
|
|||||||
System.out.println(event);
|
System.out.println(event);
|
||||||
} else {
|
} else {
|
||||||
event.apply(controller.localController);
|
event.apply(controller.localController);
|
||||||
//clientController.view.update(); TODO
|
controller.view.render();
|
||||||
}
|
}
|
||||||
} else if (read instanceof Game model) {
|
} else if (read instanceof Game model) {
|
||||||
controller.setModel(model);
|
controller.setModel(model);
|
||||||
|
controller.view.render();
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|||||||
Reference in New Issue
Block a user