Class PlacementHandler
java.lang.Object
com.alessiocascini.battleship.server.PlacementHandler
- All Implemented Interfaces:
Runnable
Handles the initial ship placement phase for a single client connection. This class reads the
ship coordinates from the client, stores them in the server's state, and synchronizes the start
of the game between players.
- Author:
- Alessio Cascini
-
Constructor Summary
ConstructorsConstructorDescriptionPlacementHandler(Socket clientSocket) Constructs a new PlacementHandler for the given client socket. * @param clientSocket The socket through which the client is connected -
Method Summary
-
Constructor Details
-
PlacementHandler
Constructs a new PlacementHandler for the given client socket. * @param clientSocket The socket through which the client is connected
-
-
Method Details
-
run
public void run()Executes the placement logic: 1. Receives ship positions from the client. 2. Registers positions in the centralServer. 3. Waits until the second player has also completed their placement. 4. Sends a confirmation to the client indicating their player role.
-