Protocol-Buffers – Best Practice for Determining Protocol Buffer Message Types

I need to serialize and deserialize a series of protocol buffer messages in the byte stream. There are some predetermined message types. What is the recommended way to encode type information so that Can my application know which type it should read?
The most common method is to use union message.

For example:

message AnyMessage {
optional Message1 msg1 = 1;
optional Message2 msg2 = 2;
...
}

Then encode/decode all messages within the AnyMessage container. Starting from protobuf 2.6, you can also use the oneof specifier, which will ensure that only one sub-message is set.

The most common method is to use union message.

For example:

message AnyMessage {
optional Message1 msg1 = 1;
optional Message2 msg2 = 2;
...
}

Then encode/decode everything in the AnyMessage container Message. Starting from protobuf 2.6, you can also use the oneof specifier, which will ensure that only one sub-message is set.

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 2485 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.