Fix: missing JavaDoc comments and parameter tags
This commit is contained in:
@@ -1,12 +1,5 @@
|
||||
package it.polimi.ingsw.gc14.Network;
|
||||
|
||||
/**
|
||||
* Represents the possible actions requested by a client and handled by the
|
||||
* server during the game.
|
||||
*
|
||||
* <p>Each value identifies a specific user action, such as adding a player,
|
||||
* choosing a slot, drawing a card, picking an optional card, or skipping an
|
||||
* optional action.
|
||||
/**
|
||||
* Represents the different types of network events that can be sent between
|
||||
* client and server.
|
||||
|
||||
@@ -30,13 +30,18 @@ public class RMIClient implements IClient {
|
||||
/** Client game's controller */
|
||||
ClientController controller;
|
||||
|
||||
/**
|
||||
* Local IP address of the RMI client.
|
||||
*/
|
||||
private String myIP;
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
* @param controller the client controller used to create the callback
|
||||
* @param host the host address of the RMI server
|
||||
* @param port the port of the RMI server
|
||||
*
|
||||
* @param controller the client controller used to create the callback.
|
||||
* @param host the host address of the RMI server.
|
||||
* @param port the port of the RMI server.
|
||||
* @param myIP the local IP address used by the RMI client.
|
||||
*/
|
||||
public RMIClient(ClientController controller, String host, int port, String myIP) {
|
||||
this.controller=controller;
|
||||
|
||||
@@ -54,11 +54,13 @@ public class RMIServer extends UnicastRemoteObject implements IGameServer {
|
||||
|
||||
/**
|
||||
* Class constructor that initializes the attributes.
|
||||
* @param controller The game controller
|
||||
* @param nPort The RMI port
|
||||
* @param actionQueue The action queue
|
||||
* @param playerList The player's usernames list
|
||||
* @throws RemoteException if an RMI error occurs
|
||||
*
|
||||
* @param controller the game controller.
|
||||
* @param nPort the RMI port.
|
||||
* @param actionQueue the action queue.
|
||||
* @param playerList the players' usernames list.
|
||||
* @param host the host address of the RMI server.
|
||||
* @throws RemoteException if an RMI error occurs.
|
||||
*/
|
||||
public RMIServer(GameController controller, int nPort, BlockingQueue<NetworkEvent> actionQueue,LimitedList<String> playerList,String host) throws RemoteException {
|
||||
this.controller = controller;
|
||||
@@ -68,9 +70,6 @@ public class RMIServer extends UnicastRemoteObject implements IGameServer {
|
||||
this.host = host;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// RMI's exposed methods
|
||||
/**
|
||||
* Allows a player to join the game.
|
||||
* If the desired number of player is invalid, the request is rejected.
|
||||
@@ -220,8 +219,13 @@ public class RMIServer extends UnicastRemoteObject implements IGameServer {
|
||||
|
||||
// RMI's internal methods
|
||||
/**
|
||||
* Sends an action to all RMI clients.
|
||||
* @param action The desired action
|
||||
* Sends an action to the RMI clients.
|
||||
*
|
||||
* <p>If the action is an error, it is sent only to the client associated with
|
||||
* the action username. Otherwise, it is sent to all connected RMI clients.
|
||||
*
|
||||
* @param action the network action to send.
|
||||
* @throws RemoteException if an RMI communication error occurs.
|
||||
*/
|
||||
public void notifyAll(NetworkEvent action) throws RemoteException {
|
||||
for (Map.Entry<String,IClientCallback> entry : clients.entrySet()) {
|
||||
@@ -233,7 +237,9 @@ public class RMIServer extends UnicastRemoteObject implements IGameServer {
|
||||
|
||||
/**
|
||||
* Sends a game model to all RMI clients.
|
||||
* @param model The desired model
|
||||
*
|
||||
* @param model the game model to send to all connected RMI clients.
|
||||
* @throws RemoteException if an RMI communication error occurs.
|
||||
*/
|
||||
public void notifyAll(Game model) throws RemoteException {
|
||||
for (IClientCallback cb : clients.values()) {
|
||||
|
||||
@@ -19,6 +19,12 @@ public class ClientHandler implements Runnable {
|
||||
* The username of the connected client on this handler
|
||||
*/
|
||||
private final String username;
|
||||
|
||||
/**
|
||||
* Returns the username associated with this client.
|
||||
*
|
||||
* @return the username associated with this client.
|
||||
*/
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
@@ -44,6 +50,7 @@ public class ClientHandler implements Runnable {
|
||||
/**
|
||||
* Class constructor that initializes the attributes.
|
||||
*
|
||||
* @param username the username associated with the client.
|
||||
* @param clientSocket the socket representing the client's TCP connection.
|
||||
* @param out the output stream used to send data to the client.
|
||||
* @param in the input stream used to receive data from the client.
|
||||
|
||||
@@ -65,10 +65,8 @@ public class TCPServer {
|
||||
* Starts the TCP server.
|
||||
* If the first event is not AddPlayer, the request is rejected.
|
||||
* If the desired number of player is invalid, the request is rejected.
|
||||
*
|
||||
* If this is the first player to connect, a new game model is created and passed to the controller. Additionally, the playerList's limit is set.
|
||||
* If the controller successfully adds the player, the username is added to {@link #playerList} and the handler is added to {@link #clientHandlers}.
|
||||
*
|
||||
* If any error occurs, the server sends -1 back to the client. Otherwise, it sends 1.
|
||||
*/
|
||||
public void start(){
|
||||
|
||||
Reference in New Issue
Block a user