Package com.rcll.llsf_comm
Class ProtobufMessage
- java.lang.Object
-
- com.rcll.llsf_comm.ProtobufMessage
-
public class ProtobufMessage extends java.lang.ObjectThis class is a wrapper for protobuf messages. It is used to identify incoming messages via the component and message IDs. To send a protobuf message, create an instance of this class with the same component ID and message ID as defined in the corresponding .proto file of the protobuf message you want to send. Then use the setter to add an instance of the actual protobuf message. You can find a detailed example in the tutorial.
-
-
Field Summary
Fields Modifier and Type Field Description protected intcmp_idstatic intFRAME_HEADER_SIZEstatic intMESSAGE_HEADER_SIZEprotected byte[]msgprotected intmsg_idprotected intpayload_sizeprotected intprotocolVersionprotected intreserved1protected intreserved2
-
Constructor Summary
Constructors Constructor Description ProtobufMessage(int cmp_id, int msg_id)Instantiates a new ProtobufMessage.ProtobufMessage(int cmp_id, int msg_id, com.google.protobuf.GeneratedMessageV3 gmsg)Instantiates a new ProtobufMessage with an instance of the actual protobuf message.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intget_component_id()Gets the component ID of the message.byte[]get_message()Gets the protobuf message as a byte array.intget_message_id()Gets the message ID of the message.intget_size()Gets the size of the message.java.nio.ByteBufferserialize(boolean encrypt, com.rcll.llsf_comm.BufferEncryptor encryptor)Serializes the ProtobufMessage.voidset_component_id(int cmp_id)Sets the component ID of the message.voidset_message(com.google.protobuf.GeneratedMessageV3 gmsg)Sets the protobuf message.voidset_message_id(int msg_id)Sets the message ID of the message.
-
-
-
Field Detail
-
protocolVersion
protected int protocolVersion
-
reserved1
protected int reserved1
-
reserved2
protected int reserved2
-
payload_size
protected int payload_size
-
cmp_id
protected int cmp_id
-
msg_id
protected int msg_id
-
msg
protected byte[] msg
-
FRAME_HEADER_SIZE
public static final int FRAME_HEADER_SIZE
- See Also:
- Constant Field Values
-
MESSAGE_HEADER_SIZE
public static final int MESSAGE_HEADER_SIZE
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ProtobufMessage
public ProtobufMessage(int cmp_id, int msg_id)Instantiates a new ProtobufMessage. Pass the same component ID and message ID as defined in the corresponding .proto file of the protobuf message you want to send.- Parameters:
cmp_id- the component ID defined in the .proto filemsg_id- the message ID defined in the .proto file
-
ProtobufMessage
public ProtobufMessage(int cmp_id, int msg_id, com.google.protobuf.GeneratedMessageV3 gmsg)Instantiates a new ProtobufMessage with an instance of the actual protobuf message. Pass the same component ID and message ID as defined in the corresponding .proto file of the protobuf message you want to send. You can find a detailed example in the tutorial.- Parameters:
cmp_id- the component ID defined in the .proto filemsg_id- the message ID defined in the .proto filegmsg- the instance of the actual protobuf message
-
-
Method Detail
-
get_component_id
public int get_component_id()
Gets the component ID of the message.- Returns:
- the component ID
-
get_message_id
public int get_message_id()
Gets the message ID of the message.- Returns:
- the message ID
-
get_size
public int get_size()
Gets the size of the message. Will return 0 if no message has been set yet.- Returns:
- the size of the message
-
get_message
public byte[] get_message()
Gets the protobuf message as a byte array.- Returns:
- the protobuf message
-
set_component_id
public void set_component_id(int cmp_id)
Sets the component ID of the message. Pass the same component ID as defined in the corresponding .proto file of the protobuf message you want to send.- Parameters:
cmp_id- the component ID
-
set_message_id
public void set_message_id(int msg_id)
Sets the message ID of the message. Pass the same message ID as defined in the corresponding .proto file of the protobuf message you want to send.- Parameters:
msg_id- the message ID
-
set_message
public void set_message(com.google.protobuf.GeneratedMessageV3 gmsg)
Sets the protobuf message. Pass an instance of the actual protobuf message you want to send.- Parameters:
gmsg- the protobuf message, has to extend from GeneratedMessage
-
serialize
public java.nio.ByteBuffer serialize(boolean encrypt, com.rcll.llsf_comm.BufferEncryptor encryptor)Serializes the ProtobufMessage. This method will automatically be called by the ProtobufClient/ProtobufBroadcastPeer when the message is to be sent out.- Returns:
- the ByteBuffer containing the ProtobufMessage
-
-