Add: ClientLauncherTUI. Connection and model sending works.

Note: ClientController.view is commented out since class TUI is still missing
This commit is contained in:
2026-04-29 17:14:45 +02:00
parent a699826137
commit 73b5b6eba5
10 changed files with 91 additions and 47 deletions
@@ -5,6 +5,7 @@ import it.polimi.ingsw.gc14.Model.Game;
import it.polimi.ingsw.gc14.Network.NetworkEvent;
import it.polimi.ingsw.gc14.Network.RMI.Common.IClientCallback;
import java.io.Serializable;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
@@ -13,7 +14,7 @@ import java.rmi.server.UnicastRemoteObject;
* RMI client callback implementation of {@link IClientCallback}.
* Receives notifications from the server and updates the client game model.
*/
public class ClientCallbackImpl extends UnicastRemoteObject implements IClientCallback {
public class ClientCallbackImpl extends UnicastRemoteObject implements IClientCallback, Serializable {
/** The client controller used to apply events and update the model */
private final ClientController clientController;
@@ -7,7 +7,6 @@ import it.polimi.ingsw.gc14.Controller.ClientController;
import it.polimi.ingsw.gc14.Network.NetworkEvent;
import it.polimi.ingsw.gc14.Network.RMI.Common.IClientCallback;
import it.polimi.ingsw.gc14.Network.RMI.Common.IGameServer;
import it.polimi.ingsw.gc14.Network.RMI.Server.RMIServer;
/**
* Client RMI. Uses the methods exposed by the server RMI.
@@ -3,9 +3,10 @@ package it.polimi.ingsw.gc14.Network.RMI.Common;
import it.polimi.ingsw.gc14.Model.Game;
import it.polimi.ingsw.gc14.Network.NetworkEvent;
import java.io.Serializable;
import java.rmi.*;
public interface IClientCallback extends Remote {
public interface IClientCallback extends Remote, Serializable {
void onGameInit(Game model) throws RemoteException;
void onAction(NetworkEvent action) throws RemoteException;
}
@@ -21,7 +21,7 @@ import java.rmi.*;
/**
* Server RMI. Exposes a method to join the game and one to execute an event.
*/
public class RMIServer implements IGameServer {
public class RMIServer extends UnicastRemoteObject implements IGameServer {
/** Server game's controller */
private GameController controller;
@@ -88,12 +88,13 @@ public class RMIServer implements IGameServer {
playerList.setLimit(preferredInt);
}
if (controller.addPlayer(username)) {
playerList.add(username);
clients.put(username, callback);
playerList.add(username);
return true;
}
return false;
}
}