Class GamesManager
java.lang.Object
it.polimi.ingsw.communication.sugar_framework.message_processing.SugarMessageProcessor
it.polimi.ingsw.server.controller.games_manager.GamesManager
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) ScheduledThreadPoolExecutorprivate final List<GameController>private final GamesRepositoryprivate final SugarServer -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbase(SugarMessage sugarMessage, Peer peer) voidbaseLowerLayers(SugarMessage message, Peer receiver) voidchatMsg(SugarMessage message, Peer peer) Sends a chat message to other players It can send to another player in the same game, otherwise can multicast the message to the team, or to all the game's participantsprivate voidcreateMatchIfPossible(int numberOfPlayers, boolean expertMode) Creates a match if there are players in the matchmaking list that satisfies the constraintsprivate Optional<GameController>findGameInvolvingPeer(Peer peer) private Optional<GameController>findGameInvolvingPlayer(String player) private voidgameLogicMulticast(GameController gameController, SugarMessage message) Multicast the message to all the players connected to the gamegetGamesMsg(SugarMessage message, Peer peer) Returns the games where the user is playingjoinMatchMakingMsg(SugarMessage message, Peer peer) Join MatchMaking Controller If a user is not in the matchmaking, it'll be added to the matchmaking list it does nothing if a user is already in the matchmaking, it will be added to the matchmaking with the newest configuration otherwisevoidokAndUpdateMsg(SugarMessage message, Peer receiver) voidpeerDisconnectedFromGameMsg(SugarMessage message, Peer peer) If the users disconnects, it waits 30 seconds If the user reconnects to the server, the game will not be closed, will be closed otherwisevoidRecovers all the matches from the repositoryreJoinMsg(SugarMessage sugarMessage, Peer peer) private voidsend(SugarMessage message, Peer peer) Methods inherited from class it.polimi.ingsw.communication.sugar_framework.message_processing.SugarMessageProcessor
drop, process, process, processFromLowerLayers
-
Field Details
-
games
-
server
-
matchMakingList
-
gamesRepository
-
executorService
ScheduledThreadPoolExecutor executorService
-
-
Constructor Details
-
GamesManager
-
-
Method Details
-
getGamesMsg
Returns the games where the user is playing- Parameters:
message-peer-- Returns:
- a GamesUpdateMsg
-
joinMatchMakingMsg
Join MatchMaking Controller If a user is not in the matchmaking, it'll be added to the matchmaking list it does nothing if a user is already in the matchmaking, it will be added to the matchmaking with the newest configuration otherwise- Parameters:
message-peer-- Returns:
- an OKMsg
-
recoverCurrentGames
public void recoverCurrentGames()Recovers all the matches from the repository -
createMatchIfPossible
private void createMatchIfPossible(int numberOfPlayers, boolean expertMode) Creates a match if there are players in the matchmaking list that satisfies the constraints- Parameters:
numberOfPlayers- of the matchexpertMode- of the match
-
reJoinMsg
-
findGameInvolvingPeer
-
findGameInvolvingPlayer
-
chatMsg
Sends a chat message to other players It can send to another player in the same game, otherwise can multicast the message to the team, or to all the game's participants- Parameters:
message-peer-
-
send
-
gameLogicMulticast
Multicast the message to all the players connected to the game- Parameters:
gameController- of the gamemessage- to send
-
peerDisconnectedFromGameMsg
If the users disconnects, it waits 30 seconds If the user reconnects to the server, the game will not be closed, will be closed otherwise- Parameters:
message-peer-
-
okAndUpdateMsg
-
baseLowerLayers
-
base
-