Package it.polito.appeal.traci.protocol

## Class ResponseMessage

- java.lang.Object
- - it.polito.appeal.traci.protocol.ResponseMessage

-     public class ResponseMessage
      extends 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​(DataInputStream dis)` | Constructor that unpacks all the data from a `DataInputStream`, populating the list of `ResponseContainer`s.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `List<ResponseContainer>` | `responses()` |

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### STATUS_ONLY_RESPONSES

          public static final int[] STATUS_ONLY_RESPONSES

      The list of IDs of responses that have no response commands.

  - ### Constructor Detail

    - #### ResponseMessage

          public ResponseMessage​(DataInputStream dis)
                          throws IOException

      Constructor that unpacks all the data from a `DataInputStream`, populating the list of `ResponseContainer`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.
      A new `ResponseMessage`, collecting all the data that belong to the same request, is built and appended to an internal list.
      Parameters:
        `dis` - dis
      Throws:
        `IOException` - Exception

  - ### Method Detail

    - #### responses

          public List<ResponseContainer> responses()