Package za.co.wethinkcode.robots.client
Class ClientState
java.lang.Object
za.co.wethinkcode.robots.client.ClientState
Utility class for storing the memory of a client's session
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordRecord for client side debugging -
Constructor Summary
ConstructorsConstructorDescriptionDefault empty constructor for client memory's memory of a sessionClientState(Map<String, ClientRobot> currentUsersRobots) -
Method Summary
Modifier and TypeMethodDescriptionbooleanaddRobot(ServerResponse response, ClientRobot robot) add a bot to the client memory and return true if it was addedaddToClientMemory(ClientCommandRequest request, ServerResponse response) Add a roundTrip of request and response to the client's memoryvoidchangeState(ClientCommandRequest request, ServerResponse response) Getter for the currently selected targetGetter for getting the names of the bots added to the client's memoryparseRoundTrip(ClientCommandRequest request, String response, com.fasterxml.jackson.databind.ObjectMapper map) Parse a client request response roundtripvoidsetCurrentRobotFromName(String robotName) Set the current robot based on its namevoidsetCurrentTarget(ClientRobot currentTarget) Setter for the currentTarget in the memory of this session
-
Constructor Details
-
ClientState
public ClientState()Default empty constructor for client memory's memory of a session -
ClientState
-
-
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 commandresponse- the response to that request- Throws:
ParsingFailedExceptioncom.fasterxml.jackson.core.JsonProcessingException
-
setCurrentRobotFromName
Set the current robot based on its name- Parameters:
robotName- name of the robot being selected as the current bot
-
setCurrentTarget
Setter for the currentTarget in the memory of this session- Parameters:
currentTarget- which robot is the target of your commands
-
getCurrentTarget
Getter for the currently selected target- Returns:
- the current target
-
getCurrentUsersRobotsNames
Getter for getting the names of the bots added to the client's memory- Returns:
- names of all the client's robots
-