Package it.polito.appeal.traci.protocol
Class ResponseMessage
- java.lang.Object
-
- it.polito.appeal.traci.protocol.ResponseMessage
-
public class ResponseMessage extends java.lang.Object
Represents a message sent from the server. A response message is made of an ordered collection of status responses, response commands and/or sub-responses.- Author:
- Enrico Gueli <enrico.gueli@polito.it>
-
-
Field Summary
Fields Modifier and Type Field Description static int[]
STATUS_ONLY_RESPONSES
The list of IDs of responses that have no response commands.
-
Constructor Summary
Constructors Constructor Description ResponseMessage(java.io.DataInputStream dis)
Constructor that unpacks all the data from aDataInputStream
, populating the list ofResponseContainer
s.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.List<ResponseContainer>
responses()
-
-
-
Constructor Detail
-
ResponseMessage
public ResponseMessage(java.io.DataInputStream dis) throws java.io.IOException
Constructor that unpacks all the data from aDataInputStream
, populating the list ofResponseContainer
s.A response message is made of individual packets. It is assumed that the first packet is always a status response. According to the status response, different data are expected next:
- if the status response is not
Constants.RTYPE_OK
, another status response or the end of the stream are expected. - if the status ID is equal to
Constants.CMD_SIMSTEP
, it is expected an integer representing N and N following sub-responses; - if the status ID matches one of the commands in
STATUS_ONLY_RESPONSES
, it is expected another status response; - if the status ID doesn't match any of the above, it is expected a response command.
ResponseMessage
, collecting all the data that belong to the same request, is built and appended to an internal list.- Parameters:
dis
- dis- Throws:
java.io.IOException
- Exception
- if the status response is not
-
-
Method Detail
-
responses
public java.util.List<ResponseContainer> responses()
-
-