Files
Progetto-ingegneria-del-sof…/src/main/java/it/polimi/ingsw/gc14/ClientLauncherTUI.java
T
GabrieleRadice b3ece597e1 Add: TODO.
2026-04-30 18:49:43 +02:00

53 lines
1.6 KiB
Java

package it.polimi.ingsw.gc14;
import it.polimi.ingsw.gc14.Controller.ClientController;
import it.polimi.ingsw.gc14.Network.RMI.Client.RMIClient;
import it.polimi.ingsw.gc14.View.IView;
import java.util.Scanner;
public class ClientLauncherTUI {
//TODO Javadoc
public void main() throws InterruptedException {
ClientController controller = new ClientController();
Scanner scanner = new Scanner(System.in);
System.out.println("Selezionare nome utente: ");
String username = scanner.next();
System.out.println(username);
System.out.println("Selezionare numero di giocatori desiderato: ");
int proposedNumPlayers = scanner.nextInt();
System.out.println(proposedNumPlayers);
System.out.println("Selezionare RMI[0] o TCP[1]: ");
int networkType = scanner.nextInt();
System.out.println(networkType);
scanner.close();
if (networkType == 0) {
RMIClient client = new RMIClient("localhost", 1099);
if (client.connect(username, proposedNumPlayers, controller)) {
System.out.println("Succesfully connected to RMI server\n\n");
} else {
System.out.println("RMI connection refused\n\n");
}
while(true) {
System.out.flush();
if (controller.localModel!=null) {
break;
}
Thread.sleep(500);
}
System.out.println("Model set\n\n");
} else if (networkType == 1) {
return;
}
}
}