From 3f727335a9c4e28d2131ce7c647ab1634e959cd9 Mon Sep 17 00:00:00 2001 From: AleandroPagani Date: Sat, 25 Apr 2026 19:11:33 +0200 Subject: [PATCH] Add: Complete JavaDOC to RMIServer --- .../gc14/Network/RMI/Server/RMIServer.java | 38 +++++++++++++++++-- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/src/main/java/it/polimi/ingsw/gc14/Network/RMI/Server/RMIServer.java b/src/main/java/it/polimi/ingsw/gc14/Network/RMI/Server/RMIServer.java index d960cc1..3578350 100644 --- a/src/main/java/it/polimi/ingsw/gc14/Network/RMI/Server/RMIServer.java +++ b/src/main/java/it/polimi/ingsw/gc14/Network/RMI/Server/RMIServer.java @@ -64,6 +64,7 @@ public class RMIServer implements IGameServer { } + // RMI's exposed methods /** * Allows a player to join the game. @@ -94,18 +95,36 @@ public class RMIServer implements IGameServer { return false; } } + + + /** + * Push an action in actionQueue. + * @param action The desired actio + * @return true if the action was successfully added, false otherwise + */ @Override - public boolean doEvent(NetworkEvent event) throws RemoteException { - return actionQueue.offer(event); + public boolean doEvent(NetworkEvent action) { + return actionQueue.offer(action); } - // Metodi interni del server + + // RMI's internal methods + /** + * Sends an action to all RMI clients. + * @param action The desired action + */ public void notifyAll(NetworkEvent action) throws RemoteException { for (IClientCallback cb : clients.values()) { cb.onAction(action); } } + + + /** + * Sends a model game to all RMI clients. + * @param model The desired model + */ public void notifyAll(Game model) throws RemoteException { for (IClientCallback cb : clients.values()) { cb.onGameInit(model); @@ -113,12 +132,17 @@ public class RMIServer implements IGameServer { } + // Metodi per avviare server RMI + /** + * Starts the RMI server. + * @return true if the server starts successfully, false otherwise + */ public boolean start() { try { registry = LocateRegistry.createRegistry(nPort); registry.rebind("RMIGameServer", this); - System.out.println("RMI Server avviato sulla porta "+nPort); + System.out.println("RMI Server started on port: "+nPort); return true; } catch (Exception e) { @@ -126,6 +150,12 @@ public class RMIServer implements IGameServer { return false; } } + + + /** + * Stops the RMI server. + * @return true if the server stops successfully, false otherwise + */ public boolean stop() { try { registry.unbind("RMIGameServer");