Class ClientReader

java.lang.Object
it.polimi.ingsw.Client.CLI.ClientReader
All Implemented Interfaces:
Runnable

public class ClientReader extends Object implements Runnable
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final ClientView
    The object used to store the client's game data
    (package private) final CyclicBarrier
    The reference to the CLIWriter class (used only in CLI mode)
    private final SocketWrapper
    The socketWrapper used to receive messages from the server
  • Constructor Summary

    Constructors
    Constructor
    Description
    ClientReader(SocketWrapper socketWrapper, ClientView clientView, CyclicBarrier cyclicBarrier)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    private void
    AnalyzeResponse(Message serverResponse)
    Method responsible for analyze Server's response and modify client's view basing on response Furthermore it prints some useful information to update the player
    private void
    This method clears Client's console
    void
    run()
    Keep listening the socket
    private void
    Support method responsible for clearing CLI and print updated model by using view's printing methods, not used to print winners
    private void
    Support method responsible for printing game's winners

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • cyclicBarrier

      final CyclicBarrier cyclicBarrier
      The reference to the CLIWriter class (used only in CLI mode)
    • socketWrapper

      private final SocketWrapper socketWrapper
      The socketWrapper used to receive messages from the server
    • clientView

      private final ClientView clientView
      The object used to store the client's game data
  • Constructor Details

  • Method Details

    • run

      public void run()
      Keep listening the socket
      Specified by:
      run in interface Runnable
    • AnalyzeResponse

      private void AnalyzeResponse(Message serverResponse) throws Exception
      Method responsible for analyze Server's response and modify client's view basing on response Furthermore it prints some useful information to update the player
      Parameters:
      serverResponse - message received from Server
      Throws:
      Exception - Necessary to handle synchronization and view's update's exceptions
    • ClearCLI

      private void ClearCLI()
      This method clears Client's console
    • UpdateView

      private void UpdateView()
      Support method responsible for clearing CLI and print updated model by using view's printing methods, not used to print winners
    • UpdateViewWin

      private void UpdateViewWin(List<String> winners)
      Support method responsible for printing game's winners
      Parameters:
      winners - list of String containing winners' nicknames