Fix: RMI no localhost
This commit is contained in:
@@ -26,7 +26,7 @@ import java.rmi.*;
|
||||
* Server RMI. Exposes a method to join the game and one to execute an event.
|
||||
*/
|
||||
public class RMIServer extends UnicastRemoteObject implements IGameServer {
|
||||
|
||||
private String host;
|
||||
/** Server game's controller */
|
||||
private GameController controller;
|
||||
|
||||
@@ -60,11 +60,12 @@ public class RMIServer extends UnicastRemoteObject implements IGameServer {
|
||||
* @param playerList The player's usernames list
|
||||
* @throws RemoteException if an RMI error occurs
|
||||
*/
|
||||
public RMIServer(GameController controller, int nPort, BlockingQueue<NetworkEvent> actionQueue,LimitedList<String> playerList) throws RemoteException {
|
||||
public RMIServer(GameController controller, int nPort, BlockingQueue<NetworkEvent> actionQueue,LimitedList<String> playerList,String host) throws RemoteException {
|
||||
this.controller = controller;
|
||||
this.nPort = nPort;
|
||||
this.actionQueue = actionQueue;
|
||||
this.playerList = playerList;
|
||||
this.host = host;
|
||||
}
|
||||
|
||||
|
||||
@@ -249,9 +250,7 @@ public class RMIServer extends UnicastRemoteObject implements IGameServer {
|
||||
*/
|
||||
public boolean start() {
|
||||
try {
|
||||
String ip = InetAddress.getLocalHost().getHostAddress();
|
||||
System.out.println("Starting RMI Server on IP: " + ip);
|
||||
System.setProperty("java.rmi.server.hostname", "10.8.0.3"); // o il tuo IP/hostname
|
||||
System.setProperty("java.rmi.server.hostname", host); // o il tuo IP/hostname
|
||||
registry = LocateRegistry.createRegistry(nPort);
|
||||
registry.rebind("RMIGameServer", this);
|
||||
System.out.println("RMI Server started on port: "+nPort);
|
||||
|
||||
Reference in New Issue
Block a user