public abstract class Sim0MQMessage extends Object implements Serializable
Copyright (c) 2016-2017 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See Sim0MQ License.
Modifier and Type | Class and Description |
---|---|
static class |
Sim0MQMessage.Builder<B extends Sim0MQMessage.Builder<B>>
Builder for the Sim0MQMessage.
|
Modifier and Type | Field and Description |
---|---|
protected static String |
VERSION
version of the protocol, magic number.
|
Constructor and Description |
---|
Sim0MQMessage(Object simulationRunId,
Object senderId,
Object receiverId,
Object messageTypeId,
long messageId,
MessageStatus messageStatus)
Encode the object array into a message.
|
Modifier and Type | Method and Description |
---|---|
static void |
check(Object[] fields,
int expectedPayloadFields,
String expectedMessageType,
Object intendedReceiverId)
Check the consistency of a message from an Object[] that was received.
|
abstract byte[] |
createByteArray()
Create a byte array of the fields.
|
abstract Object[] |
createObjectArray()
Create a Sim0MQ object array of the fields.
|
long |
getMessageId() |
MessageStatus |
getMessageStatus() |
Object |
getMessageTypeId() |
Object |
getReceiverId() |
Object |
getSenderId() |
Object |
getSimulationRunId() |
protected static final String VERSION
public Sim0MQMessage(Object simulationRunId, Object senderId, Object receiverId, Object messageTypeId, long messageId, MessageStatus messageStatus) throws Sim0MQException, NullPointerException
simulationRunId
- the Simulation run ids can be provided in 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.messageStatus
- Three different status messages are defined: 1 for new, 2 for change, and 3 for delete. This field
is coded as a byte.Sim0MQException
- on unknown data typeNullPointerException
- when one of the parameters is nullpublic final Object getSimulationRunId()
public final Object getSenderId()
public final Object getReceiverId()
public final Object getMessageTypeId()
public final long getMessageId()
public final MessageStatus getMessageStatus()
public abstract Object[] createObjectArray()
public abstract byte[] createByteArray() throws Sim0MQException, org.djutils.serialization.SerializationException
Sim0MQException
- on unknown data type as part of the contentorg.djutils.serialization.SerializationException
- when the byte array cannot be created, e.g. because the number of bytes does not matchpublic static void check(Object[] fields, int expectedPayloadFields, String expectedMessageType, Object intendedReceiverId) throws Sim0MQException
fields
- Object[]; the fields in the messageexpectedPayloadFields
- the expected number of payload fieldsexpectedMessageType
- the expected message typeintendedReceiverId
- id of the intended receiverSim0MQException
- when errors in the message have been detectedCopyright © 2016–2019 Delft University of Technology. All rights reserved.