Class GUISocketListener
java.lang.Object
it.polimi.ingsw.Client.GUI.Listeners.GUISocketListener
- All Implemented Interfaces:
Runnable
Handles messages received from server and keep a record of current player's actions executed during its turn
-
Field Summary
Modifier and TypeFieldDescriptionprivate final Context
Context received from GameInProgressPanelprivate GameInProgressPanel
JTabbedPane containing all others JPanelsprivate PlayerAction
Last player's request sent to Serverprivate final List<Pair<PlayerAction,
PlayerActionFeedback>> List of actions executed by current player and their feedbacksprivate final SocketWrapper
SocketWrapper used to communicate with Server -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Check to see if a newPlayerActionRequest
can be sent to the server or if the gui should wait before allowing any more actions to be sentint
getSuccessfulRequestsByType
(Class<?> playerActionClass) Count PlayerActions that have received a successful response from Servervoid
run()
Listen for Server's responses and updated window basing on responsesvoid
savePlayerActionRequest
(PlayerAction playerActionRequest) Save user's request that will be added in history after receiving its feedback
-
Field Details
-
requestAndFeedback
List of actions executed by current player and their feedbacks -
ctx
Context received from GameInProgressPanel -
sw
SocketWrapper used to communicate with Server -
gameInProgressPanel
JTabbedPane containing all others JPanels -
playerActionRequest
Last player's request sent to Server
-
-
Constructor Details
-
GUISocketListener
Create a new GUIReader- Parameters:
ctx
- Context containing socket and GUI's window
-
-
Method Details
-
run
public void run()Listen for Server's responses and updated window basing on responses -
savePlayerActionRequest
Save user's request that will be added in history after receiving its feedback- Parameters:
playerActionRequest
- playerActionRequest to save
-
awaitingPlayerActionFeedback
public boolean awaitingPlayerActionFeedback()Check to see if a newPlayerActionRequest
can be sent to the server or if the gui should wait before allowing any more actions to be sent- Returns:
- true if the listener is polling for a feedback to a previous player's action, false otherwise
-
getSuccessfulRequestsByType
Count PlayerActions that have received a successful response from Server- Parameters:
playerActionClass
- PlayerAction's class that will be counted- Returns:
- PlayerAction amount that received a successful response from Server
-