Class 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 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 ResponseContainers.

        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