public final class SimulationMessage extends Object
Copyright (c) 2016-2019 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See Sim0MQ License.
Modifier and Type | Method and Description |
---|---|
static Object[] |
decode(byte[] bytes)
Decode the message into an object array.
|
static byte[] |
encodeReplyUTF16(String identity,
Object simulationRunId,
Object senderId,
Object receiverId,
Object messageTypeId,
long messageId,
MessageStatus messageStatus,
Object... content)
Encode the object array into a reply message.
|
static byte[] |
encodeReplyUTF8(String identity,
Object simulationRunId,
Object senderId,
Object receiverId,
Object messageTypeId,
long messageId,
MessageStatus messageStatus,
Object... content)
Encode the object array into a reply message.
|
static byte[] |
encodeUTF16(Object simulationRunId,
Object senderId,
Object receiverId,
Object messageTypeId,
long messageId,
MessageStatus messageStatus,
Object... content)
Encode the object array into a message.
|
static byte[] |
encodeUTF8(Object simulationRunId,
Object senderId,
Object receiverId,
Object messageTypeId,
long messageId,
MessageStatus messageStatus,
Object... content)
Encode the object array into a message.
|
static String |
listPayload(Object[] message)
Return a printable line with the payload of the message, e.g.
|
static String |
print(Object[] message)
Return a printable version of the message, e.g.
|
public static byte[] encodeUTF8(Object simulationRunId, Object senderId, Object receiverId, Object messageTypeId, long messageId, MessageStatus messageStatus, Object... content) throws Sim0MQException, org.djutils.serialization.SerializationException
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.content
- the objects to encodeSim0MQException
- on unknown data typeorg.djutils.serialization.SerializationException
- on serialization problempublic static byte[] encodeUTF16(Object simulationRunId, Object senderId, Object receiverId, Object messageTypeId, long messageId, MessageStatus messageStatus, Object... content) throws Sim0MQException, org.djutils.serialization.SerializationException
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.content
- the objects to encodeSim0MQException
- on unknown data typeorg.djutils.serialization.SerializationException
- on serialization problempublic static byte[] encodeReplyUTF8(String identity, Object simulationRunId, Object senderId, Object receiverId, Object messageTypeId, long messageId, MessageStatus messageStatus, Object... content) throws Sim0MQException, org.djutils.serialization.SerializationException
identity
- the identity of the federate to which this is the replysimulationRunId
- 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.content
- the objects to encodeSim0MQException
- on unknown data typeorg.djutils.serialization.SerializationException
- on serialization problempublic static byte[] encodeReplyUTF16(String identity, Object simulationRunId, Object senderId, Object receiverId, Object messageTypeId, long messageId, MessageStatus messageStatus, Object... content) throws Sim0MQException, org.djutils.serialization.SerializationException
identity
- the identity of the federate to which this is the replysimulationRunId
- 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.content
- the objects to encodeSim0MQException
- on unknown data typeorg.djutils.serialization.SerializationException
- on serialization problempublic static Object[] decode(byte[] bytes) throws Sim0MQException, org.djutils.serialization.SerializationException
bytes
- the ZeroMQ byte array to decodeSim0MQException
- on unknown data typeorg.djutils.serialization.SerializationException
- when deserialization failspublic static String print(Object[] message)
message
- the message to parseCopyright © 2016–2019 Delft University of Technology. All rights reserved.