Add: Complete JavaDOC to RMIServer
This commit is contained in:
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user