Fix: client TCP complete connection and receive game model
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
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.Network.TCP.Client.TCPClient;
|
||||
import it.polimi.ingsw.gc14.View.IView;
|
||||
|
||||
import java.util.Scanner;
|
||||
@@ -13,21 +14,18 @@ public class ClientLauncherTUI {
|
||||
|
||||
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)) {
|
||||
RMIClient client = new RMIClient(controller, "localhost", 1099);
|
||||
if (client.connect(username, proposedNumPlayers)) {
|
||||
System.out.println("Succesfully connected to RMI server\n\n");
|
||||
} else {
|
||||
System.out.println("RMI connection refused\n\n");
|
||||
@@ -49,7 +47,26 @@ public class ClientLauncherTUI {
|
||||
|
||||
|
||||
} else if (networkType == 1) {
|
||||
return;
|
||||
TCPClient client = new TCPClient(controller, "localhost", 8080);
|
||||
if (client.start(username, proposedNumPlayers)) {
|
||||
System.out.println("Succesfully connected to TCP server\n\n");
|
||||
} else {
|
||||
System.out.println("TCP connection refused\n\n");
|
||||
}
|
||||
|
||||
while(true) {
|
||||
System.out.flush();
|
||||
if (controller.localModel!=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.localModel);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user