public class GamesManager extends SugarMessageProcessor
  • Field Details

  • Constructor Details

    • GamesManager

      public GamesManager(SugarServer server)
  • Method Details

    • getGamesMsg

      public SugarMessage getGamesMsg(SugarMessage message, Peer peer)
      Returns the games where the user is playing
      Parameters:
      message -
      peer -
      Returns:
      a GamesUpdateMsg
    • joinMatchMakingMsg

      public SugarMessage joinMatchMakingMsg(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 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 match
      expertMode - of the match
    • reJoinMsg

      public SugarMessage reJoinMsg(SugarMessage sugarMessage, Peer peer)
    • findGameInvolvingPeer

      private Optional<GameController> findGameInvolvingPeer(Peer peer)
    • findGameInvolvingPlayer

      private Optional<GameController> findGameInvolvingPlayer(String player)
    • chatMsg

      public void chatMsg(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 participants
      Parameters:
      message -
      peer -
    • send

      private void send(SugarMessage message, Peer peer)
    • gameLogicMulticast

      private void gameLogicMulticast(GameController gameController, SugarMessage message)
      Multicast the message to all the players connected to the game
      Parameters:
      gameController - of the game
      message - to send
    • peerDisconnectedFromGameMsg

      public void peerDisconnectedFromGameMsg(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 otherwise
      Parameters:
      message -
      peer -
    • okAndUpdateMsg

      public void okAndUpdateMsg(SugarMessage message, Peer receiver)
    • baseLowerLayers

      public void baseLowerLayers(SugarMessage message, Peer receiver)
    • base

      public SugarMessage base(SugarMessage sugarMessage, Peer peer)