53 lines
1.6 KiB
Java
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;
|
|
}
|
|
}
|
|
} |