Add: Complete JavaDOC to RMIServer
This commit is contained in:
@@ -64,6 +64,7 @@ public class RMIServer implements IGameServer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// RMI's exposed methods
|
// RMI's exposed methods
|
||||||
/**
|
/**
|
||||||
* Allows a player to join the game.
|
* Allows a player to join the game.
|
||||||
@@ -94,18 +95,36 @@ public class RMIServer implements IGameServer {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Push an action in actionQueue.
|
||||||
|
* @param action The desired actio
|
||||||
|
* @return true if the action was successfully added, false otherwise
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean doEvent(NetworkEvent event) throws RemoteException {
|
public boolean doEvent(NetworkEvent action) {
|
||||||
return actionQueue.offer(event);
|
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 {
|
public void notifyAll(NetworkEvent action) throws RemoteException {
|
||||||
for (IClientCallback cb : clients.values()) {
|
for (IClientCallback cb : clients.values()) {
|
||||||
cb.onAction(action);
|
cb.onAction(action);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends a model game to all RMI clients.
|
||||||
|
* @param model The desired model
|
||||||
|
*/
|
||||||
public void notifyAll(Game model) throws RemoteException {
|
public void notifyAll(Game model) throws RemoteException {
|
||||||
for (IClientCallback cb : clients.values()) {
|
for (IClientCallback cb : clients.values()) {
|
||||||
cb.onGameInit(model);
|
cb.onGameInit(model);
|
||||||
@@ -113,12 +132,17 @@ public class RMIServer implements IGameServer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Metodi per avviare server RMI
|
// Metodi per avviare server RMI
|
||||||
|
/**
|
||||||
|
* Starts the RMI server.
|
||||||
|
* @return true if the server starts successfully, false otherwise
|
||||||
|
*/
|
||||||
public boolean start() {
|
public boolean start() {
|
||||||
try {
|
try {
|
||||||
registry = LocateRegistry.createRegistry(nPort);
|
registry = LocateRegistry.createRegistry(nPort);
|
||||||
registry.rebind("RMIGameServer", this);
|
registry.rebind("RMIGameServer", this);
|
||||||
System.out.println("RMI Server avviato sulla porta "+nPort);
|
System.out.println("RMI Server started on port: "+nPort);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
@@ -126,6 +150,12 @@ public class RMIServer implements IGameServer {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stops the RMI server.
|
||||||
|
* @return true if the server stops successfully, false otherwise
|
||||||
|
*/
|
||||||
public boolean stop() {
|
public boolean stop() {
|
||||||
try {
|
try {
|
||||||
registry.unbind("RMIGameServer");
|
registry.unbind("RMIGameServer");
|
||||||
|
|||||||
Reference in New Issue
Block a user