Protocol buffers are not self-describing, so in general there is no practical way to interpret a serialized protocol buffer unless you already know its message type.
If you need to work with two message types A and B, you might find it easiest to just use a wrapper message containing a oneof <https://developers.google.com/protocol-buffers/docs/proto#using-oneof> field that could hold either A or B. That way you always know the message type (MyWrapperMessage or whatever), and once you parse it you can look inside to see if it was an A or B. On Tue, Nov 8, 2016 at 7:52 PM, KMG <[email protected]> wrote: > hello! dears. > > i recieved some byte[] from server. > i need to use MessageParser for deserializing them. > > but I can't determine type of byte[]. > > somebody can solve this problem? > > ex) > byte[] recievedBytes = ....; > > MyProtobufClass.Parser.ParseFrom(recievedBytes); > > but i can't sure recievedBytes are MyProtobufClass... > > please. help me. > > -- > 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 [email protected]. > To post to this group, send email to [email protected]. > Visit this group at https://groups.google.com/group/protobuf. > For more options, visit https://groups.google.com/d/optout. > -- 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 [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/protobuf. For more options, visit https://groups.google.com/d/optout.
