Package it.polimi.ingsw.Client
Class SocketClient
java.lang.Object
it.polimi.ingsw.Client.SocketClient
Socket Client abstraction, attached to terminal and GUI views
- Author:
- Gruppo AM34
-
Field Summary
Modifier and TypeFieldDescriptionprivate static final int
private static final ExecutorService
private static boolean
private static final int
private static final int
private static OutputAbstraction
private static int
private static final ScheduledExecutorService
private static String
private static final TerminalAbstraction
private static final BufferedReader
private static final PrintWriter
private static boolean
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprivate static void
communication
(Socket socket) this method manages communication phases between Server and Client (Client side)static void
login
(BufferedReader in, PrintWriter out) this method manages login phasestatic void
Main method, welcoming Server management consolestatic void
makeMove
(PrintWriter out, ProducerConsumerLock lineLockers, AtomicReference<String> lineBuffer) this method manages move phaseprivate static void
readServerLine
(BufferedReader in, ProducerConsumerLock lineLockers, AtomicReference<String> lineBuffer) Socket thread listenerstatic boolean
turnManagement
(ProducerConsumerLock lineLockers, AtomicReference<String> lineBuffer, AtomicReference<String> currentPlayer, ClientCommonGoalCard c1, ClientCommonGoalCard c2, boolean clientsTurn, AtomicInteger points) this method manages the turn evolution
-
Field Details
-
KA_FREQUENCY
private static final int KA_FREQUENCY- See Also:
-
KA_MAXCOUNT
private static final int KA_MAXCOUNT- See Also:
-
countParameters
private static final int countParameters- See Also:
-
terminalOutput
-
terminalInput
-
ta
-
executors
-
scheduledExecutors
-
serverName
-
portNumber
private static int portNumber -
useGUI
private static boolean useGUI -
firstTime
private static boolean firstTime -
oa
-
-
Constructor Details
-
SocketClient
public SocketClient()
-
-
Method Details
-
main
Main method, welcoming Server management console- Parameters:
args
- default arguments array
-
communication
this method manages communication phases between Server and Client (Client side)- Parameters:
socket
- socket- Throws:
IOException
- input/output exception
-
readServerLine
private static void readServerLine(BufferedReader in, ProducerConsumerLock lineLockers, AtomicReference<String> lineBuffer) throws IOException, InterruptedException Socket thread listener- Parameters:
in
- bufferedReaderlineLockers
- ProducerConsumerLocklineBuffer
- line read by the thread- Throws:
IOException
- input/output exceptionInterruptedException
- related to RMI
-
login
this method manages login phase- Parameters:
in
- BufferedReaderout
- PrintWriter- Throws:
IOException
- input/output exception
-
turnManagement
public static boolean turnManagement(ProducerConsumerLock lineLockers, AtomicReference<String> lineBuffer, AtomicReference<String> currentPlayer, ClientCommonGoalCard c1, ClientCommonGoalCard c2, boolean clientsTurn, AtomicInteger points) throws RemoteException this method manages the turn evolution- Parameters:
lineLockers
- ProducerConsumerLocklineBuffer
- line read by the threadcurrentPlayer
- currentPlayerc1
- CommonGoalCard1c2
- CommonGoalCard2clientsTurn
- true if it's clientsTurn, false otherwisepoints
- scores achieved by the player (CommonGoal)- Returns:
- true if the client will play the next turn
- Throws:
RemoteException
- related to RMI
-
makeMove
public static void makeMove(PrintWriter out, ProducerConsumerLock lineLockers, AtomicReference<String> lineBuffer) this method manages move phase- Parameters:
out
- printwriterlineLockers
- ProducerConsumerLocklineBuffer
- line read by the thread
-