Package org.sim0mq.message
Class Sim0MQReply
java.lang.Object
org.sim0mq.message.Sim0MQMessage
org.sim0mq.message.Sim0MQReply
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
HB2AliveMessage
,MC1StatusMessage
,MC2AckNakMessage
The abstract body of a reply message with the first fields of every Sim0MQ reply message.
Copyright (c) 2016-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See Sim0MQ License.
- Author:
- Alexander Verbraeck
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Sim0MQReply.Builder<B extends Sim0MQMessage.Builder<B>>
Builder for the Sim0MQReply. -
Field Summary
Fields inherited from class org.sim0mq.message.Sim0MQMessage
VERSION
-
Constructor Summary
ConstructorDescriptionSim0MQReply
(boolean bigEndian, Object federationId, Object senderId, Object receiverId, Object messageTypeId, Object messageId, Object[] payload) Encode the object array into a message.Sim0MQReply
(Object[] objectArray, int expectedNumberOfPayloadFields, Object expectedMessageTypeId) Encode the object array into a message. -
Method Summary
Methods inherited from class org.sim0mq.message.Sim0MQMessage
check, createByteArray, createObjectArray, decode, decodeToArray, encodeReplyUTF16, encodeReplyUTF8, encodeUTF16, encodeUTF8, getFederationId, getMagicNumber, getMessageId, getMessageTypeId, getNumberOfPayloadFields, getReceiverId, getSenderId, isBigEndian, listPayload, print
-
Constructor Details
-
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 typeNullPointerException
- 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 arrayexpectedNumberOfPayloadFields
- 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 typeNullPointerException
- when one of the parameters is null
-
-
Method Details
-
getReplyToId
- Returns:
- replyToId
-