Class ServerResponseHandler

java.lang.Object
java.lang.Thread
it.polimi.ingsw.am13.client.network.socket.ServerResponseHandler
All Implemented Interfaces:
Runnable

public class ServerResponseHandler extends Thread
This class keeps waiting for responses coming from the server. Depending on the received message, it calls the corresponding GameStateHandler and View methods.
  • Field Details

    • socket

      private final Socket socket
      The socket which is used to communicate with the server
    • gameStateHandler

      private GameStateHandler gameStateHandler
      Handler of the representation of the game state
    • networkHandlerSocket

      private final NetworkHandlerSocket networkHandlerSocket
      The socket network handler that sends the messages from the client to the server
    • view

      private final View view
      The user interface
    • chat

      private Chat chat
      Chat storing all the messages involving this player
  • Constructor Details

    • ServerResponseHandler

      public ServerResponseHandler(Socket socket, NetworkHandlerSocket networkHandlerSocket, View view)
      Constructor of this class, that sets the socket, network handler and view
      Parameters:
      socket - to communicate with the server
      networkHandlerSocket - that sends the messages from the client to the server
      view - of this client, where the updates received from the server are shown
  • Method Details

    • run

      public void run()
      Thread run method that waits for messages coming from the server, and updates the view and the game state according to the received message
      Specified by:
      run in interface Runnable
      Overrides:
      run in class Thread