java.lang.Object
test.BookScrabbleHandler
- All Implemented Interfaces:
ClientHandler
-
Constructor Summary
ConstructorsConstructorDescriptionThe BookScrabbleHandler function is a constructor that initializes the DictionaryManager, and creates an array of Strings to hold the names of books. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()The close function is used to stop the thread from running.voidhandleClient(Socket client) The handleClient function is called by the server when a new client connects.
-
Constructor Details
-
BookScrabbleHandler
public BookScrabbleHandler()The BookScrabbleHandler function is a constructor that initializes the DictionaryManager, and creates an array of Strings to hold the names of books. It also sets stop to false.
-
-
Method Details
-
handleClient
The handleClient function is called by the server when a new client connects. It reads in the word that was sent from the client and checks if it is in either of our dictionaries. If it is, then we send back "true" to indicate that this word exists, otherwise we send back "false". We also check for any challenge words sent from clients and add them to our dictionary if they are not already there.- Specified by:
handleClientin interfaceClientHandler- Parameters:
client- Socket
-
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
-