Fix: ClientLauncher local IP select

This commit is contained in:
2026-05-05 19:34:43 +02:00
parent 7cba416a5a
commit 384df3c0a6
2 changed files with 48 additions and 4 deletions
@@ -30,6 +30,7 @@ public class RMIClient implements IClient {
/** Client game's controller */
ClientController controller;
private String myIP;
/**
* Class constructor.
@@ -37,10 +38,11 @@ public class RMIClient implements IClient {
* @param host the host address of the RMI server
* @param port the port of the RMI server
*/
public RMIClient(ClientController controller, String host, int port) {
public RMIClient(ClientController controller, String host, int port, String myIP) {
this.controller=controller;
this.host = host;
this.port = port;
this.myIP = myIP;
}
@@ -54,8 +56,7 @@ public class RMIClient implements IClient {
*/
public boolean connect(String username,int preferredInt) {
try {
String ip = InetAddress.getLocalHost().getHostAddress();
System.setProperty("java.rmi.server.hostname", ip);
System.setProperty("java.rmi.server.hostname", this.myIP);
Registry registry = LocateRegistry.getRegistry(host, port);
this.stub = (IGameServer) registry.lookup("RMIGameServer");
ClientCallbackImpl callback = new ClientCallbackImpl(controller);