Class Server

java.lang.Object
it.polimi.ingsw.network.server.Server

public class Server
extends java.lang.Object
This class accepts connection to a client and assign the client handling to the ServerClientHandler class via Thread. Also handles match creation, deletion and player assignment to matches.
  • Field Summary

    Fields
    Modifier and Type Field Description
    static int MAX_PORT_NUMBER  
    static int MIN_PORT_NUMBER  
  • Constructor Summary

    Constructors
    Constructor Description
    Server()  
  • Method Summary

    Modifier and Type Method Description
    Match assignToMatch​(java.lang.String matchId, Message message, ServerClientHandler serverClientHandler)
    assigns a player to the specified match
    Match createNewMatch​(java.lang.String matchId)
    Creates a new match with the specified Id
    void deleteMatch​(java.lang.String matchId)
    Deletes the specified match from the server
    static void main​(java.lang.String[] args)  
    java.lang.Boolean matchIdPresent​(java.lang.String matchId)
    Returns true if the specified matchId is already present in the server

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • Server

      public Server()
  • Method Details

    • createNewMatch

      public Match createNewMatch​(java.lang.String matchId)
      Creates a new match with the specified Id
      Parameters:
      matchId - the unique identifier for the match to be created
      Returns:
      the new created Match
    • assignToMatch

      public Match assignToMatch​(java.lang.String matchId, Message message, ServerClientHandler serverClientHandler)
      assigns a player to the specified match
      Parameters:
      matchId - the matchId to be joined
      message - the login message sent by the client
      serverClientHandler - the clientHandler to be added to the match
      Returns:
      the match to which the client has been added
    • matchIdPresent

      public java.lang.Boolean matchIdPresent​(java.lang.String matchId)
      Returns true if the specified matchId is already present in the server
      Parameters:
      matchId - the matchId to be checked if already present
      Returns:
      true if the specified matchId is already present
    • deleteMatch

      public void deleteMatch​(java.lang.String matchId)
      Deletes the specified match from the server
      Parameters:
      matchId - the match to be deleted
    • main

      public static void main​(java.lang.String[] args)