Class ProtobufMessage


  • public class ProtobufMessage
    extends java.lang.Object
    This 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.
    • 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
      int get_component_id()
      Gets the component ID of the message.
      byte[] get_message()
      Gets the protobuf message as a byte array.
      int get_message_id()
      Gets the message ID of the message.
      int get_size()
      Gets the size of the message.
      java.nio.ByteBuffer serialize​(boolean encrypt, com.rcll.llsf_comm.BufferEncryptor encryptor)
      Serializes the ProtobufMessage.
      void set_component_id​(int cmp_id)
      Sets the component ID of the message.
      void set_message​(com.google.protobuf.GeneratedMessageV3 gmsg)
      Sets the protobuf message.
      void set_message_id​(int msg_id)
      Sets the message ID of the message.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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
    • 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 file
        msg_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 file
        msg_id - the message ID defined in the .proto file
        gmsg - 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