java.lang.Object
it.polimi.ingsw.controller.MessageManagerParser
- All Implemented Interfaces:
ServerMessageManagerVisitor
public class MessageManagerParser extends java.lang.Object implements ServerMessageManagerVisitor
Handles incoming messages from the client and their respective responses
In particular, this class' objects handle all the messages regarding the actual game, from the choice of the gods
to the winner declaration.
It also provides the only contact point between the game controller and the outside world, via the
parseMessageFromServerToClient(Message) method.
-
Constructor Summary
Constructors Constructor Description MessageManagerParser(Lobby lobby)Default constructor -
Method Summary
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface it.polimi.ingsw.controller.ServerMessageManagerVisitor
createLobby, joinLobby, login
-
Constructor Details
-
MessageManagerParser
Default constructorEvery
Lobbyis linked to a parser, which manages the incoming messages from the lobby's users; The serverController has to be set separately, since it can be set up in different moments- Parameters:
lobby- the lobby associated to this parser
-
-
Method Details
-
setServerController
Sets the parser's game controller- Parameters:
serverController- the game controller associated to this parser
-
parseMessageFromServerToClient
Sends a messageSince the parser has no reference to the network interface, the message has to be sent to the lobby, which will take care of sending the message, using the Lobby.sendMessage(String, Message) method.
- Parameters:
message- the message to send
-
onMatchReloadResponse
Handles a ChooseToReloadMatchResponse message- Specified by:
onMatchReloadResponsein interfaceServerMessageManagerVisitor- Parameters:
message- the message to handle- See Also:
Lobby.reloadMatch(boolean)
-
chooseInitialGods
Handles a ChooseInitialGodsResponse message- Specified by:
chooseInitialGodsin interfaceServerMessageManagerVisitor- Parameters:
message- the message to handle- See Also:
Lobby.chooseGods(List)
-
chooseGod
Handles a ChooseYourGodResponse message- Specified by:
chooseGodin interfaceServerMessageManagerVisitor- Parameters:
message- the message to handle- See Also:
Lobby.assignGod(String, GodData)
-
chooseStartingPlayer
Handles a ChooseStartingPlayerResponse message- Specified by:
chooseStartingPlayerin interfaceServerMessageManagerVisitor- Parameters:
message- the message to handle- See Also:
Lobby.selectStartingPlayer(String)
-
selectWorker
Handles a SelectWorkerRequest message- Specified by:
selectWorkerin interfaceServerMessageManagerVisitor- Parameters:
message- the message to handle- See Also:
ServerController.selectWorker(String, Worker)
-
walkableCells
Handles a WalkableCellsRequest message- Specified by:
walkableCellsin interfaceServerMessageManagerVisitor- Parameters:
message- the message to handle- See Also:
ServerController.obtainWalkableCells(String)
-
buildableCells
Handles a BuildableCellsRequest message- Specified by:
buildableCellsin interfaceServerMessageManagerVisitor- Parameters:
message- the message to handle- See Also:
ServerController.obtainBuildableCells(String)
-
selectCellToBuild
Handles a SelectBuildingCellRequest message- Specified by:
selectCellToBuildin interfaceServerMessageManagerVisitor- Parameters:
message- the message to handle- See Also:
ServerController.selectBuildingCell(String, Cell)
-
managePlayerMove
Handles a PlayerMoveRequest message- Specified by:
managePlayerMovein interfaceServerMessageManagerVisitor- Parameters:
message- the message to handle- See Also:
ServerController.handleMoveAction(String, MoveAction)
-
managePlayerBuild
Handles a PlayerBuildRequest message- Specified by:
managePlayerBuildin interfaceServerMessageManagerVisitor- Parameters:
message- the message to handle- See Also:
ServerController.handleBuildAction(String, BuildAction)
-
addWorkerOnBoard
Handles a AddWorkerRequest message- Specified by:
addWorkerOnBoardin interfaceServerMessageManagerVisitor- Parameters:
message- the message to handle- See Also:
ServerController.addWorker(String, Cell)
-
endTurn
Handles a EndTurnRequest message- Specified by:
endTurnin interfaceServerMessageManagerVisitor- Parameters:
message- the message to handle- See Also:
ServerController.onTurnEnd(String, List)
-
cannotHandleMessage
Invoked in case the message received has a Visitor method not implemented in this parser. In this case, it has been decided to ignore the message and literally take no action, leading the client to doom.- Specified by:
cannotHandleMessagein interfaceServerMessageManagerVisitor- Parameters:
message- the message to discard
-