Class ClientState

java.lang.Object
za.co.wethinkcode.robots.client.ClientState

public class ClientState extends Object
Utility class for storing the memory of a client's session
  • Constructor Details

    • ClientState

      public ClientState()
      Default empty constructor for client memory's memory of a session
    • ClientState

      public ClientState(Map<String,ClientRobot> currentUsersRobots)
  • Method Details

    • parseRoundTrip

      public ServerResponse parseRoundTrip(ClientCommandRequest request, String response, com.fasterxml.jackson.databind.ObjectMapper map) throws ParsingFailedException, com.fasterxml.jackson.core.JsonProcessingException, com.fasterxml.jackson.core.JsonProcessingException
      Parse a client request response roundtrip
      Parameters:
      request - the request to execute a command
      response - the response to that request
      Throws:
      ParsingFailedException
      com.fasterxml.jackson.core.JsonProcessingException
    • addRobot

      public boolean addRobot(ServerResponse response, ClientRobot robot)
      add a bot to the client memory and return true if it was added
      Parameters:
      response - serverResponse
      robot - the robot being added
      Returns:
      if the addition was successful
    • setCurrentRobotFromName

      public void setCurrentRobotFromName(String robotName)
      Set the current robot based on its name
      Parameters:
      robotName - name of the robot being selected as the current bot
    • setCurrentTarget

      public void setCurrentTarget(ClientRobot currentTarget)
      Setter for the currentTarget in the memory of this session
      Parameters:
      currentTarget - which robot is the target of your commands
    • getCurrentTarget

      public ClientRobot getCurrentTarget()
      Getter for the currently selected target
      Returns:
      the current target
    • addToClientMemory

      public String addToClientMemory(ClientCommandRequest request, ServerResponse response)
      Add a roundTrip of request and response to the client's memory
      Parameters:
      request - request that a command be executed
      response - response from the server
    • changeState

      public void changeState(ClientCommandRequest request, ServerResponse response) throws ServerRobotFailedException
      Throws:
      ServerRobotFailedException
    • getCurrentUsersRobotsNames

      public Set<String> getCurrentUsersRobotsNames()
      Getter for getting the names of the bots added to the client's memory
      Returns:
      names of all the client's robots