Package it.polimi.ingsw.network.server
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 intMAX_PORT_NUMBERstatic intMIN_PORT_NUMBER -
Constructor Summary
Constructors Constructor Description Server() -
Method Summary
Modifier and Type Method Description MatchassignToMatch(java.lang.String matchId, Message message, ServerClientHandler serverClientHandler)assigns a player to the specified matchMatchcreateNewMatch(java.lang.String matchId)Creates a new match with the specified IdvoiddeleteMatch(java.lang.String matchId)Deletes the specified match from the serverstatic voidmain(java.lang.String[] args)java.lang.BooleanmatchIdPresent(java.lang.String matchId)Returns true if the specified matchId is already present in the serverMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
MIN_PORT_NUMBER
public static final int MIN_PORT_NUMBER- See Also:
- Constant Field Values
-
MAX_PORT_NUMBER
public static final int MAX_PORT_NUMBER- See Also:
- Constant Field Values
-
-
Constructor Details
-
Server
public Server()
-
-
Method Details
-
createNewMatch
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 joinedmessage- the login message sent by the clientserverClientHandler- 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)
-