I have the following message structures that compiles smoothly in protoc.exe
message MessageBase {
    extensions 2;
    required Header header = 1;
}

message Message1 {
  extends MessageBase {
    optional Message1 message = 2;
  }
  optional int32 id = 1;
}

message Message2 {
  extends MessageBase {
    optional Message2 message = 2;
  }
  optional int32 count = 1;
}

What is the fastest way to encode and decode Message1 and Message2?

Let's assume that from Header field, we can know if message is Message1 or 
Message2 instance. So far I have the following code (in Java):

Header header = M3apMessage.parseFrom( data ).getHeader();
switch( header.getMessageType ){
  case Message1:
    //How to decode the rest of the bytes as stated in Message1 structure
  break;

  case Message2:
    //How to decode the rest of the bytes as stated in Message2 structure
  break;
}

Thanks in advance!

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to protobuf+unsubscr...@googlegroups.com.
To post to this group, send email to protobuf@googlegroups.com.
Visit this group at http://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.

Reply via email to