Package Model

Class HostServer


public class HostServer extends Observable
  • Constructor Details

    • HostServer

      public HostServer(int myPort, ClientHandler ch, String gameServerIp, int gameServerPort)
      HostServer constructor --> create a new HostServer.
      Parameters:
      myPort - --> the port of the HostServer
      gameServerIp - --> the ip of the game server
      gameServerPort - --> the port of the game server
  • Method Details

    • getBookNames

      public List<String> getBookNames()
    • startServer

      public void startServer()
      startServer --> start the server in a thread
    • stop

      public void stop()
    • close

      public void close()
      close --> close the server and all the sockets
    • addSocket

      public void addSocket(int id, Socket socket)
      addSocket --> add a socket to the clientsSockets map
      Parameters:
      id - --> the id of the Player
      socket - --> the socket of the Player
    • sendToBookScrabbleServer

      public Socket sendToBookScrabbleServer(String type, String word)
      sendToGameServer --> send a query or a challenge to the game server
      Parameters:
      type - --> "Q" for query or "C" for challenge
      word - --> the word to be queried or challenged
    • sendToSpecificPlayer

      public void sendToSpecificPlayer(int playerID, String methodName, String output)
      sendToSpecificPlayer --> send a message to a specific player
      Parameters:
      playerID - --> the id of the player
      methodName - --> the method to notify the players about
      output - --> the output of the method
    • sendToSpecificPlayer

      public void sendToSpecificPlayer(int playerId, String message)
    • sendToAllPlayers

      public void sendToAllPlayers(int playerID, String methodName, String output)
      sendToAllPlayers --> send a message to all players
      Parameters:
      playerID - --> the id of the player to notify about
      methodName - --> the method to notify the players about
      output - --> the output of the method
    • sendToAllPlayers

      public void sendToAllPlayers(String message)
    • setChanged

      public void setChanged()
      Overrides:
      setChanged in class Observable