Fix: small change to how clients connect
This commit is contained in:
@@ -2,6 +2,7 @@ package it.polimi.ingsw.gc14;
|
||||
|
||||
import it.polimi.ingsw.gc14.Controller.ClientController;
|
||||
import it.polimi.ingsw.gc14.Model.GamePackage.GameStages;
|
||||
import it.polimi.ingsw.gc14.Network.IClient;
|
||||
import it.polimi.ingsw.gc14.Network.NetworkConfig;
|
||||
import it.polimi.ingsw.gc14.Network.InterfaceResolver;
|
||||
import it.polimi.ingsw.gc14.Network.RMI.Client.RMIClient;
|
||||
@@ -174,6 +175,7 @@ public class ClientLauncherTUI {
|
||||
view.setUsername(username);
|
||||
controller.setMyUsername(username);
|
||||
|
||||
IClient client;
|
||||
if (networkStr.equals("rmi")) {
|
||||
String myIP;
|
||||
try {
|
||||
@@ -183,7 +185,7 @@ public class ClientLauncherTUI {
|
||||
return false;
|
||||
}
|
||||
System.setProperty("java.rmi.server.hostname", myIP);
|
||||
RMIClient client = new RMIClient(controller, ip, NetworkConfig.RMI_PORT, myIP);
|
||||
client = new RMIClient(controller, ip, NetworkConfig.RMI_PORT, myIP);
|
||||
ErrorType err = client.connect(username, nPlayers);
|
||||
if (err != null) {
|
||||
terminal.writer().print("\033[H\033[2J");
|
||||
@@ -195,7 +197,7 @@ public class ClientLauncherTUI {
|
||||
controller.setClient(client);
|
||||
|
||||
} else if (networkStr.equals("tcp")) {
|
||||
TCPClient client = new TCPClient(controller, ip, NetworkConfig.TCP_PORT, NetworkConfig.HEARTBEAT_PORT);
|
||||
client = new TCPClient(controller, ip, NetworkConfig.TCP_PORT, NetworkConfig.HEARTBEAT_PORT);
|
||||
ErrorType err = client.connect(username, nPlayers);
|
||||
if (err != null) {
|
||||
terminal.writer().print("\033[H\033[2J");
|
||||
|
||||
@@ -2,6 +2,7 @@ package it.polimi.ingsw.gc14.View.GUI;
|
||||
|
||||
import it.polimi.ingsw.gc14.Controller.ClientController;
|
||||
import it.polimi.ingsw.gc14.ErrorType;
|
||||
import it.polimi.ingsw.gc14.Network.IClient;
|
||||
import it.polimi.ingsw.gc14.Network.NetworkConfig;
|
||||
import it.polimi.ingsw.gc14.Network.InterfaceResolver;
|
||||
import it.polimi.ingsw.gc14.Network.RMI.Client.RMIClient;
|
||||
@@ -159,8 +160,9 @@ public class LoginFXMLController {
|
||||
|
||||
/** Connects to the server using the selected protocol and transitions to the waiting state on success. */
|
||||
private void connect(String nome, String ip, int numPlayers, String localInterface) {
|
||||
IClient client;
|
||||
if (isRMI) {
|
||||
RMIClient client = new RMIClient(controller, ip, NetworkConfig.RMI_PORT, localInterface);
|
||||
client = new RMIClient(controller, ip, NetworkConfig.RMI_PORT, localInterface);
|
||||
ErrorType serverResponse = client.connect(nome, numPlayers);
|
||||
if (serverResponse == null) {
|
||||
controller.setClient(client);
|
||||
@@ -172,7 +174,7 @@ public class LoginFXMLController {
|
||||
});
|
||||
}
|
||||
} else {
|
||||
TCPClient client = new TCPClient(controller, ip, NetworkConfig.TCP_PORT, NetworkConfig.HEARTBEAT_PORT);
|
||||
client = new TCPClient(controller, ip, NetworkConfig.TCP_PORT, NetworkConfig.HEARTBEAT_PORT);
|
||||
ErrorType serverResponse = client.connect(nome, numPlayers);
|
||||
if (serverResponse == null) {
|
||||
controller.setClient(client);
|
||||
|
||||
Reference in New Issue
Block a user