Class Sim0MQReply

  • All Implemented Interfaces:
    Serializable
    Direct Known Subclasses:
    HB2AliveMessage, MC1StatusMessage, MC2AckNakMessage

    public abstract class Sim0MQReply
    extends Sim0MQMessage
    The abstract body of a reply message with the first fields of every Sim0MQ reply message.

    Copyright (c) 2016-2020 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
    BSD-style license. See Sim0MQ License.

    $LastChangedDate: 2015-07-24 02:58:59 +0200 (Fri, 24 Jul 2015) $, @version $Revision: 1147 $, by $Author: averbraeck $, initial version Apr 22, 2017
    Author:
    Alexander Verbraeck
    See Also:
    Serialized Form
    • Constructor Detail

      • Sim0MQReply

        public Sim0MQReply​(boolean bigEndian,
                           Object federationId,
                           Object senderId,
                           Object receiverId,
                           Object messageTypeId,
                           Object messageId,
                           Object[] payload)
                    throws Sim0MQException,
                           NullPointerException
        Encode the object array into a message.
        Parameters:
        bigEndian - boolean; Indicates whether this message using little endian or big endian encoding. Big endian is encoded as true, and little endian as false.
        federationId - the federation id can be coded using different types. Examples are two 64-bit longs indicating a UUID, or a String with a UUID number, a String with meaningful identification, or a short or an int with a simulation run number.
        senderId - The sender id can be used to send back a message to the sender at some later time.
        receiverId - The receiver id can be used to check whether the message is meant for us, or should be discarded (or an error can be sent if we receive a message not meant for us).
        messageTypeId - Message type ids can be defined per type of simulation, and can be provided in different types. Examples are a String with a meaningful identification, or a short or an int with a message type number.
        messageId - The unique message number is meant to confirm with a callback that the message has been received correctly. The number is unique for the sender, so not globally within the federation.
        payload - Object[]; Payload as an Object array
        Throws:
        Sim0MQException - on unknown data type
        NullPointerException - when one of the parameters is null
      • Sim0MQReply

        public Sim0MQReply​(Object[] objectArray,
                           int expectedNumberOfPayloadFields,
                           Object expectedMessageTypeId)
                    throws Sim0MQException,
                           NullPointerException
        Encode the object array into a message.
        0 = magic number, equal to the String "SIM##" where ## stands for the version number of the protocol.
        1 = endianness, boolean indicating the endianness for the message. True is Big Endian, false is Little Endian.
        2 = federation id, could be String, int, Object, ...
        3 = sender id, could be String, int, Object, ...
        4 = receiver id, could be String, int, Object, ...
        5 = message type id, could be String, int, Object, ...
        6 = message id, could be long, Object, String, ....
        7 = number of fields that follow, as a Number (byte, short, int, long).
        8-n = payload, where the number of fields was defined by message[7]. The first payload field should be the replyToId.
        Parameters:
        objectArray - Object[]; Full message object array
        expectedNumberOfPayloadFields - int; the expected number of fields in the message (field 8 and further). The payload fields should include the replyToId, so the number should be 1 or higher.
        expectedMessageTypeId - the expected message type id
        Throws:
        Sim0MQException - on unknown data type
        NullPointerException - when one of the parameters is null
    • Method Detail

      • getReplyToId

        public final Object getReplyToId()
        Returns:
        replyToId