Class PlacementHandler

java.lang.Object
com.alessiocascini.battleship.server.PlacementHandler
All Implemented Interfaces:
Runnable

public class PlacementHandler extends Object implements 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 Details

    • PlacementHandler

      public PlacementHandler(Socket clientSocket)
      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 central Server. 3. Waits until the second player has also completed their placement. 4. Sends a confirmation to the client indicating their player role.
      Specified by:
      run in interface Runnable