Package test

Class BookScrabbleHandler

java.lang.Object
test.BookScrabbleHandler
All Implemented Interfaces:
ClientHandler

public class BookScrabbleHandler extends Object implements ClientHandler
  • Constructor Summary

    Constructors
    Constructor
    Description
    The 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 Type
    Method
    Description
    void
    The close function is used to stop the thread from running.
    void
    The handleClient function is called by the server when a new client connects.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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

      public void handleClient(Socket client)
      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:
      handleClient in interface ClientHandler
      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:
      close in interface ClientHandler