Serialized protocol buffers don't contain any metadata to indicate what
type they are, so you have to have some other mechanism to know what the
type is. I would guess that your .proto file probably has a parent message
containing the other messages, and the parent is probably the one that is
always sent.

On Tue, Oct 13, 2020 at 6:25 AM Carlos Pereira <[email protected]> wrote:

> I forgot to mention that the file they sent us is using Protocol Buffers 2.
>
> BR,
>
> A terça-feira, 13 de outubro de 2020 à(s) 15:25:07 UTC+2, Carlos Pereira
> escreveu:
>
>> Hi,
>>
>> Currently I'm working with ProtoBuf at work. There's a client device that
>> sends us messages using ProtoBuf, so we can't change the protocol. The
>> first 3 bytes is the length of the ProtoBuf message with big endian bytes
>> order and then after that is the message itself. However, the .proto file
>> they sent us defines multiple types of messages.
>>
>> I'm using a CodedInputStream to first read the length of the serialized
>> message and then read this size.
>>
>> My problem is that after having bytes of the message I don't know which
>> class inside the protc generated file I should use to call the
>> *parseFrom*.
>>
>> Any idea?
>>
>>
>> Best Regards,
>>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/protobuf/94523e6f-cc14-4928-a4f6-eb3d6a7f37e8n%40googlegroups.com
> <https://groups.google.com/d/msgid/protobuf/94523e6f-cc14-4928-a4f6-eb3d6a7f37e8n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/protobuf/CADqAXr7CV5C_%2BxQ8voUG%3DDQezeEdyKKUSHxA2YNALi1PT%2B%3DXpQ%40mail.gmail.com.

Reply via email to