Package it.polimi.ingsw.Client.CLI
Class ClientReader
java.lang.Object
it.polimi.ingsw.Client.CLI.ClientReader
- All Implemented Interfaces:
Runnable
-
Field Summary
Modifier and TypeFieldDescriptionprivate 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
ConstructorDescriptionClientReader
(SocketWrapper socketWrapper, ClientView clientView, CyclicBarrier cyclicBarrier) -
Method Summary
Modifier and TypeMethodDescriptionprivate 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 playerprivate void
ClearCLI()
This method clears Client's consolevoid
run()
Keep listening the socketprivate void
Support method responsible for clearing CLI and print updated model by using view's printing methods, not used to print winnersprivate void
UpdateViewWin
(List<String> winners) Support method responsible for printing game's winners
-
Field Details
-
cyclicBarrier
The reference to the CLIWriter class (used only in CLI mode) -
socketWrapper
The socketWrapper used to receive messages from the server -
clientView
The object used to store the client's game data
-
-
Constructor Details
-
ClientReader
public ClientReader(SocketWrapper socketWrapper, ClientView clientView, CyclicBarrier cyclicBarrier)
-
-
Method Details
-
run
public void run()Keep listening the socket -
AnalyzeResponse
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
Support method responsible for printing game's winners- Parameters:
winners
- list of String containing winners' nicknames
-