Jens Rantil
unread,Mar 18, 2012, 6:41:34 PM3/18/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Sign in to report message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Protocol Buffers
Hi,
I'm a newcomer to protobuf and am trying to wrap my head around some
things. Let's say I have a message receiver of some kind. It can
receive different types requests. All messages are encoded in protobuf
and my receiver has all *.proto message definitions necessary be able
to decode all incoming requests.
My question is, does protobuf come with any bells and whistles that
let me decode a random incoming message, given all possible message
definitions? If not, how do you generally cope with this situation?
Because I feel it's a common one.
I guess one possible solution is to create another message definition:
message GenericMessage {
enum MessageType {
SET_NAME = 0;
CREATE_CUSTOMER = 1;
}
required MessageType type = 0;
required bytes protobuf_data = 1;
}
However, this would require me to do two deserializations. Is this the
prefered way to go? I'm curious to hear you input. Please pinpoint me
if this has been answered previously in forum or in the documentation.
Regards,
Jens