java.lang.Object
Model.HostHandler
- All Implemented Interfaces:
ClientHandler
-
Constructor Summary
ConstructorsConstructorDescriptionHostHandler(HostModel model) The HostHandler function is responsible for handling the Host's turn. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()The close function is used to stop the thread from running.voidhandleClient(Socket client) The handleClient function is responsible for handling the client's requests.
-
Constructor Details
-
HostHandler
The HostHandler function is responsible for handling the Host's turn. It will first check if the player has any cards in their hand, and if they do not, it will draw a card from the deck. If there are no cards left in the deck to draw from, then it will end its turn without drawing a card. The function then checks whether there are any valid moves that can be made with this new card (or old ones). If so, it makes one of these moves at random and ends its turn; otherwise, it discards this new card (or an old one) at- Parameters:
model- HostModel
-
-
Method Details
-
handleClient
The handleClient function is responsible for handling the client's requests. It reads a request from the client, and then performs an action according to that request. The function also sends back a response to the client after performing each action.- Specified by:
handleClientin interfaceClientHandler- Parameters:
client- Socket -Connect to the client
-
close
public void close()The close function is used to stop the thread from running. It sets the boolean variable "stop" to true, which causes the while loop in run() to terminate. This allows for a clean shutdown of this thread when it is no longer needed.- Specified by:
closein interfaceClientHandler
-